Skip to content

Commit 53205f5

Browse files
adamwathanclaudeRobinMalfait
authored
Add font-features-* utility for font-feature-settings (tailwindlabs#19623)
Add a new arbitrary-value-only utility `font-features-*` that sets the `font-feature-settings` CSS property. This utility only accepts arbitrary values (e.g., `font-features-["smcp"]`, `font-features-[var(--features)]`). The utility is sorted directly after `font-family` in the property order. https://claude.ai/code/session_01EAccbTHJ9dTUJ53ttq2jc4 --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Robin Malfait <malfait.robin@gmail.com>
1 parent 5395c7e commit 53205f5

4 files changed

Lines changed: 53 additions & 8 deletions

File tree

CHANGELOG.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Added
11+
12+
- _Experimental_: Add `@container-size` utility ([#18901](https://github.com/tailwindlabs/tailwindcss/pull/18901))
13+
- Add `@tailwindcss/webpack` loader for Tailwind CSS v4 ([#19610](https://github.com/tailwindlabs/tailwindcss/pull/19610))
14+
- Add `pbs-*`, `pbe-*`, `mbs-*`, `mbe-*`, `scroll-pbs-*`, `scroll-pbe-*`, `scroll-mbs-*`, `scroll-mbe-*`, `border-bs-*`, `border-be-*` utilities for `padding-block-start`, `padding-block-end`, `margin-block-start`, `margin-block-end`, `scroll-padding-block-start`, `scroll-padding-block-end`, `scroll-margin-block-start`, `scroll-margin-block-end`, `border-block-start`, and `border-block-end` ([`#19601`](https://github.com/tailwindlabs/tailwindcss/pull/19601))
15+
- Add `inline-*`, `min-inline-*`, `max-inline-*`, `block-*`, `min-block-*`, `max-block-*` utilities for `inline-size`, `min-inline-size`, `max-inline-size`, `block-size`, `min-block-size`, and `max-block-size` ([#19612](https://github.com/tailwindlabs/tailwindcss/pull/19612))
16+
- Add `inset-s-*`, `inset-e-*`, `inset-bs-*`, `inset-be-*` utilities for `inset-inline-start`, `inset-inline-end`, `inset-block-start`, and `inset-block-end` ([#19613](https://github.com/tailwindlabs/tailwindcss/pull/19613))
17+
- Add `font-features-*` utility for `font-feature-settings` ([#19623](https://github.com/tailwindlabs/tailwindcss/pull/19615))
18+
1019
### Fixed
1120

1221
- Do not wrap `color-mix` in a `@supports` rule if one already exists ([#19450](https://github.com/tailwindlabs/tailwindcss/pull/19450))
@@ -16,14 +25,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1625
- Fix class extraction for Rails' strict locals ([#19525](https://github.com/tailwindlabs/tailwindcss/pull/19525))
1726
- Align `@utility` name validation with Oxide scanner rules ([#19524](https://github.com/tailwindlabs/tailwindcss/pull/19524))
1827

19-
### Added
20-
21-
- _Experimental_: Add `@container-size` utility ([#18901](https://github.com/tailwindlabs/tailwindcss/pull/18901))
22-
- Add `@tailwindcss/webpack` loader for Tailwind CSS v4 ([#19610](https://github.com/tailwindlabs/tailwindcss/pull/19610))
23-
- Add `pbs-*`, `pbe-*`, `mbs-*`, `mbe-*`, `scroll-pbs-*`, `scroll-pbe-*`, `scroll-mbs-*`, `scroll-mbe-*`, `border-bs-*`, `border-be-*` utilities for `padding-block-start`, `padding-block-end`, `margin-block-start`, `margin-block-end`, `scroll-padding-block-start`, `scroll-padding-block-end`, `scroll-margin-block-start`, `scroll-margin-block-end`, `border-block-start`, and `border-block-end` ([`#19601`](https://github.com/tailwindlabs/tailwindcss/pull/19601))
24-
- Add `inline-*`, `min-inline-*`, `max-inline-*`, `block-*`, `min-block-*`, `max-block-*` utilities for `inline-size`, `min-inline-size`, `max-inline-size`, `block-size`, `min-block-size`, and `max-block-size` ([#19612](https://github.com/tailwindlabs/tailwindcss/pull/19612))
25-
- Add `inset-s-*`, `inset-e-*`, `inset-bs-*`, `inset-be-*` utilities for `inset-inline-start`, `inset-inline-end`, `inset-block-start`, and `inset-block-end` ([#19613](https://github.com/tailwindlabs/tailwindcss/pull/19613))
26-
2728
### Deprecated
2829

2930
- Deprecate `start-*` and `end-*` utilities in favor of `inline-s-*` and `inline-e-*` ([#19613](https://github.com/tailwindlabs/tailwindcss/pull/19613))

packages/tailwindcss/src/property-order.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,7 @@ export default [
343343
'vertical-align',
344344

345345
'font-family',
346+
'font-feature-settings',
346347
'font-size',
347348
'line-height',
348349
'font-weight',

packages/tailwindcss/src/utilities.test.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22218,6 +22218,41 @@ test('font', async () => {
2221822218
).toEqual('')
2221922219
})
2222022220

22221+
test('font-features', async () => {
22222+
expect(
22223+
await run([
22224+
'font-features-["smcp"]',
22225+
'font-features-["c2sc","smcp"]',
22226+
'font-features-[var(--my-features)]',
22227+
'font-features-(--my-features)',
22228+
]),
22229+
).toMatchInlineSnapshot(`
22230+
".font-features-\\(--my-features\\) {
22231+
font-feature-settings: var(--my-features);
22232+
}
22233+
22234+
.font-features-\\[\\"c2sc\\"\\,\\"smcp\\"\\] {
22235+
font-feature-settings: "c2sc", "smcp";
22236+
}
22237+
22238+
.font-features-\\[\\"smcp\\"\\] {
22239+
font-feature-settings: "smcp";
22240+
}
22241+
22242+
.font-features-\\[var\\(--my-features\\)\\] {
22243+
font-feature-settings: var(--my-features);
22244+
}"
22245+
`)
22246+
expect(
22247+
await run([
22248+
'font-features',
22249+
'-font-features-["smcp"]',
22250+
'font-features-smcp',
22251+
'font-features-["smcp"]/foo',
22252+
]),
22253+
).toEqual('')
22254+
})
22255+
2222122256
test('text-transform', async () => {
2222222257
expect(await run(['uppercase', 'lowercase', 'capitalize', 'normal-case'])).toMatchInlineSnapshot(`
2222322258
".capitalize {

packages/tailwindcss/src/utilities.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3909,6 +3909,14 @@ export function createUtilities(theme: Theme) {
39093909
},
39103910
])
39113911

3912+
/**
3913+
* @css `font-feature-settings`
3914+
*/
3915+
functionalUtility('font-features', {
3916+
themeKeys: [],
3917+
handle: (value) => [decl('font-feature-settings', value)],
3918+
})
3919+
39123920
staticUtility('uppercase', [['text-transform', 'uppercase']])
39133921
staticUtility('lowercase', [['text-transform', 'lowercase']])
39143922
staticUtility('capitalize', [['text-transform', 'capitalize']])

0 commit comments

Comments
 (0)