Skip to content

Commit aa15964

Browse files
authored
Use unitless line-heights for font-size variables (#15216)
Safari has an [insane bug](#15196) where if you register custom properties for gradient colors using the `"<color>"` type, you attempt to transition a gradient on an element, _and_ you set a font-size and line-height on that element that point to CSS variables defined using `rem` units, the element size changes and shifts the layout while the transition is happening: https://github.com/user-attachments/assets/46eefccf-8a12-4751-8a44-54e48c54cd06 This bug goes away if you use anything other than `rem` units for the line-height. So this PR changes all of our variables like `--text-3xl--line-height` to use unitless relative line-height values instead of fixed line-height values to workaround this bug. Not my favorite change but pretty low impact because you likely aren't going to reference those variables for much anyways. If Safari ever fixes this bug (which is still present as of Safari 18), it would be nice to swap these back to what they were. Fixes #15196. --------- Co-authored-by: Adam Wathan <4323180+adamwathan@users.noreply.github.com>
1 parent 31cfbc7 commit aa15964

File tree

4 files changed

+26
-24
lines changed

4 files changed

+26
-24
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1919
- Ensure `--spacing-*` variables take precedence over `--container-*` variables ([#15180](https://github.com/tailwindlabs/tailwindcss/pull/15180))
2020
- Fix scanning classes delimited by tab characters ([#15169](https://github.com/tailwindlabs/tailwindcss/pull/15169))
2121
- Ensure opacity modifiers and semi-transparent gradients render correctly by default in Safari ([#15201](https://github.com/tailwindlabs/tailwindcss/pull/15201))
22+
- Fix element size thrashing when transitioning gradients on elements with a defined font-size in Safari ([#15216](https://github.com/tailwindlabs/tailwindcss/pull/15216))
2223

2324
### Changed
2425

2526
- Interpolate gradients using OKLAB instead of OKLCH by default ([#15201](https://github.com/tailwindlabs/tailwindcss/pull/15201))
2627
- Error when `layer(…)` in `@import` is not first in the list of functions/conditions ([#15109](https://github.com/tailwindlabs/tailwindcss/pull/15109))
28+
- Use unitless line-height values for font-size variables in default theme ([#15216](https://github.com/tailwindlabs/tailwindcss/pull/15216))
2729

2830
## [4.0.0-beta.2] - 2024-11-22
2931

packages/@tailwindcss-postcss/src/__snapshots__/index.test.ts.snap

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -271,21 +271,21 @@ exports[`\`@import 'tailwindcss'\` is replaced with the generated CSS 1`] = `
271271
--container-7xl: 80rem;
272272
--container-prose: 65ch;
273273
--text-xs: .75rem;
274-
--text-xs--line-height: 1rem;
274+
--text-xs--line-height: calc(1 / .75);
275275
--text-sm: .875rem;
276-
--text-sm--line-height: 1.25rem;
276+
--text-sm--line-height: calc(1.25 / .875);
277277
--text-base: 1rem;
278-
--text-base--line-height: 1.5rem;
278+
--text-base--line-height: calc(1.5 / 1);
279279
--text-lg: 1.125rem;
280-
--text-lg--line-height: 1.75rem;
280+
--text-lg--line-height: calc(1.75 / 1.125);
281281
--text-xl: 1.25rem;
282-
--text-xl--line-height: 1.75rem;
282+
--text-xl--line-height: calc(1.75 / 1.25);
283283
--text-2xl: 1.5rem;
284-
--text-2xl--line-height: 2rem;
284+
--text-2xl--line-height: calc(2 / 1.5);
285285
--text-3xl: 1.875rem;
286-
--text-3xl--line-height: 2.25rem;
286+
--text-3xl--line-height: calc(2.25 / 1.875);
287287
--text-4xl: 2.25rem;
288-
--text-4xl--line-height: 2.5rem;
288+
--text-4xl--line-height: calc(2.5 / 2.25);
289289
--text-5xl: 3rem;
290290
--text-5xl--line-height: 1;
291291
--text-6xl: 3.75rem;

packages/tailwindcss/src/__snapshots__/index.test.ts.snap

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -270,21 +270,21 @@ exports[`compiling CSS > \`@tailwind utilities\` is replaced by utilities using
270270
--container-7xl: 80rem;
271271
--container-prose: 65ch;
272272
--text-xs: .75rem;
273-
--text-xs--line-height: 1rem;
273+
--text-xs--line-height: calc(1 / .75);
274274
--text-sm: .875rem;
275-
--text-sm--line-height: 1.25rem;
275+
--text-sm--line-height: calc(1.25 / .875);
276276
--text-base: 1rem;
277-
--text-base--line-height: 1.5rem;
277+
--text-base--line-height: calc(1.5 / 1);
278278
--text-lg: 1.125rem;
279-
--text-lg--line-height: 1.75rem;
279+
--text-lg--line-height: calc(1.75 / 1.125);
280280
--text-xl: 1.25rem;
281-
--text-xl--line-height: 1.75rem;
281+
--text-xl--line-height: calc(1.75 / 1.25);
282282
--text-2xl: 1.5rem;
283-
--text-2xl--line-height: 2rem;
283+
--text-2xl--line-height: calc(2 / 1.5);
284284
--text-3xl: 1.875rem;
285-
--text-3xl--line-height: 2.25rem;
285+
--text-3xl--line-height: calc(2.25 / 1.875);
286286
--text-4xl: 2.25rem;
287-
--text-4xl--line-height: 2.5rem;
287+
--text-4xl--line-height: calc(2.5 / 2.25);
288288
--text-5xl: 3rem;
289289
--text-5xl--line-height: 1;
290290
--text-6xl: 3.75rem;

packages/tailwindcss/theme.css

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -296,21 +296,21 @@
296296
--container-prose: 65ch;
297297

298298
--text-xs: 0.75rem;
299-
--text-xs--line-height: 1rem;
299+
--text-xs--line-height: calc(1 / 0.75);
300300
--text-sm: 0.875rem;
301-
--text-sm--line-height: 1.25rem;
301+
--text-sm--line-height: calc(1.25 / 0.875);
302302
--text-base: 1rem;
303-
--text-base--line-height: 1.5rem;
303+
--text-base--line-height: calc(1.5 / 1);
304304
--text-lg: 1.125rem;
305-
--text-lg--line-height: 1.75rem;
305+
--text-lg--line-height: calc(1.75 / 1.125);
306306
--text-xl: 1.25rem;
307-
--text-xl--line-height: 1.75rem;
307+
--text-xl--line-height: calc(1.75 / 1.25);
308308
--text-2xl: 1.5rem;
309-
--text-2xl--line-height: 2rem;
309+
--text-2xl--line-height: calc(2 / 1.5);
310310
--text-3xl: 1.875rem;
311-
--text-3xl--line-height: 2.25rem;
311+
--text-3xl--line-height: calc(2.25 / 1.875);
312312
--text-4xl: 2.25rem;
313-
--text-4xl--line-height: 2.5rem;
313+
--text-4xl--line-height: calc(2.5 / 2.25);
314314
--text-5xl: 3rem;
315315
--text-5xl--line-height: 1;
316316
--text-6xl: 3.75rem;

0 commit comments

Comments
 (0)