From 66be2a6bb5592fa19cd59eed25d278140be02c6f Mon Sep 17 00:00:00 2001 From: Jordan Pittman Date: Tue, 2 Dec 2025 13:14:15 -0500 Subject: [PATCH] Support bare spacing scale values for `font-size` --- packages/tailwindcss/src/theme.ts | 2 +- packages/tailwindcss/src/utilities.ts | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/packages/tailwindcss/src/theme.ts b/packages/tailwindcss/src/theme.ts index 073fb242f..800ccbeaa 100644 --- a/packages/tailwindcss/src/theme.ts +++ b/packages/tailwindcss/src/theme.ts @@ -243,7 +243,7 @@ export class Theme { } resolveWith( - candidateValue: string, + candidateValue: string | null, themeKeys: ThemeKey[], nestedKeys: `--${string}`[] = [], ): [string, Record] | null { diff --git a/packages/tailwindcss/src/utilities.ts b/packages/tailwindcss/src/utilities.ts index e1b098c2a..f975ac687 100644 --- a/packages/tailwindcss/src/utilities.ts +++ b/packages/tailwindcss/src/utilities.ts @@ -5095,6 +5095,20 @@ export function createUtilities(theme: Theme) { ['--text', '--spacing'], ['--line-height', '--letter-spacing', '--font-weight'], ) + + // Bare values use the spacing scale + if (!value) { + let multiplier = theme.resolveWith( + null, + ['--spacing'], + ['--line-height', '--letter-spacing', '--font-weight'], + ) + if (!multiplier) return + if (!isValidSpacingMultiplier(candidate.value.value)) return + + value = [`calc(${multiplier[0]} * ${candidate.value.value})`, multiplier[1]] + } + if (value) { let [fontSize, options = {}] = Array.isArray(value) ? value : [value] @@ -5158,7 +5172,7 @@ export function createUtilities(theme: Theme) { modifiers: Array.from({ length: 21 }, (_, index) => `${index * 5}`), }, { - values: [], + values: theme.get(['--spacing']) ? DEFAULT_SPACING_SUGGESTIONS : [], valueThemeKeys: ['--text', '--spacing'], modifiers: [], modifierThemeKeys: ['--leading', '--spacing'],