From 6eb3b324340f451a14389b7ed97f43a264ad4487 Mon Sep 17 00:00:00 2001 From: Robin Malfait Date: Tue, 17 Feb 2026 13:32:31 -0500 Subject: [PATCH] Allow multiples of `.25` in `aspect-*` fractions (#19688) This PR reduces the restrictions of the `aspect-*` utilities when dealing with fractional values. Up until now, the numbers had to be positive integers, so `aspect-1/2` was valid, but `aspect-8.5/11` was not. This PR allows for any multiple of `.25` as a valid value, so `aspect-8.5/11` is now valid, but `aspect-8.3/11` is not, this will still require `aspect-[8.3/11]` arbitrary value syntax to be valid. This behavior of allowing multiples of `.25` is consistent with other utilities that handle bare values such as `w-2.5`. ## Test plan 1. Existing tests pass 2. Added a test for `aspect-8.5/11` Fixes: #19663 Closes: #19680, #19669 --- CHANGELOG.md | 1 + packages/tailwindcss/src/utilities.test.ts | 7 ++++++- packages/tailwindcss/src/utilities.ts | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 55cec3e08..2eb00b020 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fix class extraction for Rails' strict locals ([#19525](https://github.com/tailwindlabs/tailwindcss/pull/19525)) - Align `@utility` name validation with Oxide scanner rules ([#19524](https://github.com/tailwindlabs/tailwindcss/pull/19524)) - Fix infinite loop when using `@variant` inside `@custom-variant` ([#19633](https://github.com/tailwindlabs/tailwindcss/pull/19633)) +- Allow multiples of `.25` in `aspect-*` fractions ([#19688](https://github.com/tailwindlabs/tailwindcss/pull/19688)) ### Deprecated diff --git a/packages/tailwindcss/src/utilities.test.ts b/packages/tailwindcss/src/utilities.test.ts index 29e8dae3a..7bd03b577 100644 --- a/packages/tailwindcss/src/utilities.test.ts +++ b/packages/tailwindcss/src/utilities.test.ts @@ -3156,7 +3156,7 @@ test('aspect-ratio', async () => { } @tailwind utilities; `, - ['aspect-video', 'aspect-[10/9]', 'aspect-4/3'], + ['aspect-video', 'aspect-[10/9]', 'aspect-4/3', 'aspect-8.5/11'], ), ).toMatchInlineSnapshot(` ":root, :host { @@ -3167,6 +3167,10 @@ test('aspect-ratio', async () => { aspect-ratio: 4 / 3; } + .aspect-8\\.5\\/11 { + aspect-ratio: 8.5 / 11; + } + .aspect-\\[10\\/9\\] { aspect-ratio: 10 / 9; } @@ -3188,6 +3192,7 @@ test('aspect-ratio', async () => { 'aspect--4/3', 'aspect--4/-3', 'aspect-4/-3', + 'aspect-1.23/4.56', ]), ).toEqual('') }) diff --git a/packages/tailwindcss/src/utilities.ts b/packages/tailwindcss/src/utilities.ts index fd524f495..015821e4e 100644 --- a/packages/tailwindcss/src/utilities.ts +++ b/packages/tailwindcss/src/utilities.ts @@ -981,7 +981,7 @@ export function createUtilities(theme: Theme) { handleBareValue: ({ fraction }) => { if (fraction === null) return null let [lhs, rhs] = segment(fraction, '/') - if (!isPositiveInteger(lhs) || !isPositiveInteger(rhs)) return null + if (!isValidSpacingMultiplier(lhs) || !isValidSpacingMultiplier(rhs)) return null return fraction }, handle: (value) => [decl('aspect-ratio', value)],