diff --git a/CHANGELOG.md b/CHANGELOG.md index 8fdc889403bc..5c88eb73ddc4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- Add `line-height` modifier support to `font-size` utilities ([#9875](https://github.com/tailwindlabs/tailwindcss/pull/9875)) + ### Fixed - Cleanup unused `variantOrder` ([#9829](https://github.com/tailwindlabs/tailwindcss/pull/9829)) diff --git a/src/corePlugins.js b/src/corePlugins.js index b9ca42f749d1..f92767e24cbe 100644 --- a/src/corePlugins.js +++ b/src/corePlugins.js @@ -1834,8 +1834,16 @@ export let corePlugins = { fontSize: ({ matchUtilities, theme }) => { matchUtilities( { - text: (value) => { + text: (value, { modifier }) => { let [fontSize, options] = Array.isArray(value) ? value : [value] + + if (modifier) { + return { + 'font-size': fontSize, + 'line-height': modifier, + } + } + let { lineHeight, letterSpacing, fontWeight } = isPlainObject(options) ? options : { lineHeight: options } @@ -1850,6 +1858,7 @@ export let corePlugins = { }, { values: theme('fontSize'), + modifiers: theme('lineHeight'), type: ['absolute-size', 'relative-size', 'length', 'percentage'], } ) diff --git a/tests/match-utilities.test.js b/tests/match-utilities.test.js index b6add847d809..918145382854 100644 --- a/tests/match-utilities.test.js +++ b/tests/match-utilities.test.js @@ -4,7 +4,9 @@ test('match utilities with modifiers', async () => { let config = { content: [ { - raw: html`
`, + raw: html` `, }, ], corePlugins: { preflight: false }, @@ -24,6 +26,7 @@ test('match utilities with modifiers', async () => { '1': 'one', '2': 'two', '1/foo': 'onefoo', + '[8]/[9]': 'eightnine', }, modifiers: 'any', } @@ -57,6 +60,9 @@ test('match utilities with modifiers', async () => { .test-1\/\[foo\] { color: one_[foo]; } + .test-\[8\]\/\[9\] { + color: eightnine_null; + } `) }) diff --git a/tests/plugins/fontSize.test.js b/tests/plugins/fontSize.test.js index f26735db94e5..5738e0a96384 100644 --- a/tests/plugins/fontSize.test.js +++ b/tests/plugins/fontSize.test.js @@ -119,3 +119,77 @@ test('font-size utilities can include a font-weight', () => { `) }) }) + +test('font-size utilities can include a line-height modifier', () => { + let config = { + content: [ + { + raw: html`