Skip to content

Conversation

@RobinMalfait
Copy link
Member

This PR fixes an issue where classes such as text-sm/none don't work as expected. The reason for this is that leading-none is the only hardcoded leading utility and is not coming from the @theme. This means that text-sm/none tries to do a lookup for none but it won't resolve.

This PR fixes that by allowing none as a modifier.

While working on this, I noticed that text-sm/none did generate CSS:

.text-sm\/none {
  font-size: var(--text-sm);
}

Notice that the line-height is missing. This means that any modifier that can't be resolved doesn't get the line-height set, but it will generate CSS. In this case, no CSS should have been generated.

Otherwise, all of these generate CSS which will only bloat your CSS and won't
work as expected. E.g.: text-sm/foo, text-sm/bar, and text-sm/baz:

.text-sm\/bar {
  font-size: var(--text-sm);
}
.text-sm\/baz {
  font-size: var(--text-sm);
}
.text-sm\/foo {
  font-size: var(--text-sm);
}

Fixes: #15911

@RobinMalfait RobinMalfait requested a review from a team as a code owner January 27, 2025 12:31
If you used `text-sm/foobar`, then this would generate:

```css
.text-sm\/foobar {
  font-size: var(--text-sm);
}
```

Even if the `/foobar` is not really used. This fixes that by ensuring
that if a modifier is used, but doesn't resolve, that it does not
generate any CSS.
`leading-none` is a hardcoded value, and is not coming from the
`@theme`. This means that this is the only modifier value you can't use
with a `text-*` utility. E.g.: `text-sm/none` will not have a
`line-height: 1;` attached.
Copy link
Member

@philipp-spiess philipp-spiess left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Font size / line height shorthand doesn't apply line-height when leading value is none

3 participants