Skip to content

Commit c0af1e2

Browse files
Fix fontSize array upgrade (#17630)
Fixes #17622. Adds a specific handling case in `themeableValues()` in `packages/tailwindcss/src/compat/apply-config-to-theme.ts`. It seems like this has unique handling in v3 for an array value, whereby the second value is treated as a `line-height`. --------- Co-authored-by: Philipp Spiess <[email protected]>
1 parent 3ab7f12 commit c0af1e2

File tree

4 files changed

+38
-1
lines changed

4 files changed

+38
-1
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313
- Ensure the `color-mix(…)` polyfill creates fallbacks for theme variables that reference other theme variables ([#17562](https://github.com/tailwindlabs/tailwindcss/pull/17562))
1414
- Fix brace expansion in `@source inline('z-{10..0}')` with range going down ([#17591](https://github.com/tailwindlabs/tailwindcss/pull/17591))
1515
- Ensure container query variant names can contain hyphens ([#17628](https://github.com/tailwindlabs/tailwindcss/pull/17628))
16+
- Ensure compatibility with array tuples used in `fontSize` JS theme keys ([#17630](https://github.com/tailwindlabs/tailwindcss/pull/17630))
17+
- Upgrade: Convert `fontSize` array tuple syntax to CSS theme variables ([#17630](https://github.com/tailwindlabs/tailwindcss/pull/17630))
1618

1719
## [4.1.3] - 2025-04-04
1820

integrations/upgrade/js-config.test.ts

+8
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ test(
3737
xs: ['0.75rem', { lineHeight: '1rem' }],
3838
sm: ['0.875rem', { lineHeight: '1.5rem' }],
3939
base: ['1rem', { lineHeight: '2rem' }],
40+
lg: ['1.125rem', '2.5rem'],
41+
xl: ['1.5rem', '3rem', 'invalid'],
42+
'2xl': ['2rem'],
4043
},
4144
width: {
4245
px: '1px',
@@ -188,6 +191,11 @@ test(
188191
--text-sm--line-height: 1.5rem;
189192
--text-base: 1rem;
190193
--text-base--line-height: 2rem;
194+
--text-lg: 1.125rem;
195+
--text-lg--line-height: 2.5rem;
196+
--text-xl: 1.5rem;
197+
--text-xl--line-height: 3rem;
198+
--text-2xl: 2rem;
191199
192200
--width-*: initial;
193201
--width-0: 0%;

packages/tailwindcss/src/compat/apply-config-to-theme.test.ts

+18
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ test('config values can be merged into the theme', () => {
5252
lineHeight: '1.5',
5353
},
5454
],
55+
lg: ['1.125rem', '2'],
56+
xl: ['1.5rem', '3rem', 'invalid'],
57+
'2xl': ['2rem'],
5558
},
5659

5760
letterSpacing: {
@@ -102,6 +105,21 @@ test('config values can be merged into the theme', () => {
102105
'1rem',
103106
{ '--line-height': '1.5' },
104107
])
108+
expect(theme.resolve('lg', ['--text'])).toEqual('1.125rem')
109+
expect(theme.resolveWith('lg', ['--text'], ['--line-height'])).toEqual([
110+
'1.125rem',
111+
{ '--line-height': '2' },
112+
])
113+
expect(theme.resolve('xl', ['--text'])).toEqual('1.5rem')
114+
expect(theme.resolveWith('xl', ['--text'], ['--line-height'])).toEqual([
115+
'1.5rem',
116+
{ '--line-height': '3rem' },
117+
])
118+
expect(theme.resolve('2xl', ['--text'])).toEqual('2rem')
119+
expect(theme.resolveWith('2xl', ['--text'], ['--line-height'])).toEqual([
120+
'2rem',
121+
{},
122+
])
105123
expect(theme.resolve('super-wide', ['--tracking'])).toEqual('0.25em')
106124
expect(theme.resolve('super-loose', ['--leading'])).toEqual('3')
107125
expect(theme.resolve('1/2', ['--width'])).toEqual('60%')

packages/tailwindcss/src/compat/apply-config-to-theme.ts

+10-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,16 @@ export function themeableValues(config: ResolvedConfig['theme']): [string[], unk
130130
}
131131

132132
if (Array.isArray(value) && value.every((v) => typeof v === 'string')) {
133-
toAdd.push([path, value.join(', ')])
133+
if (path[0] === 'fontSize') {
134+
toAdd.push([path, value[0]])
135+
136+
if (value.length >= 2) {
137+
toAdd.push([[...path, '-line-height'], value[1]])
138+
}
139+
} else {
140+
toAdd.push([path, value.join(', ')])
141+
}
142+
134143
return WalkAction.Skip
135144
}
136145
})

0 commit comments

Comments
 (0)