Skip to content

Add bare value support for auto-rows-* and auto-cols-*#20229

Open
RobinMalfait wants to merge 4 commits into
mainfrom
feat/allow-spacing-values-in-auto-rows-cols
Open

Add bare value support for auto-rows-* and auto-cols-*#20229
RobinMalfait wants to merge 4 commits into
mainfrom
feat/allow-spacing-values-in-auto-rows-cols

Conversation

@RobinMalfait

@RobinMalfait RobinMalfait commented Jun 12, 2026

Copy link
Copy Markdown
Member

This PR adds bare value support for auto-rows-* and auto-cols-*.

We first introduced auto-rows-auto, auto-rows-min, auto-rows-max and auto-rows-fr (same for auto-cols-*) back in Tailwind CSS v1.9 (https://v1.tailwindcss.com/docs/grid-auto-rows#app) but we haven't touched it since.

This PR now adds support for bare values that use the spacing scale. That means that you can now use auto-rows-12 or auto-cols-12 which will result in the following CSS:

.auto-cols-12 {
  grid-auto-columns: calc(var(--spacing) * 12);
}
.auto-rows-12 {
  grid-auto-rows: calc(var(--spacing) * 12);
}

We could also add support for percentage based values. The only question is what the syntax should be. This can either be auto-rows-3/4 or auto-rows-75%.

For the fraction case, we already have w-3/4 and aspect-3/4 even though they both have a different value as a result:

.aspect-3\/4 {
  aspect-ratio: 3/4;
}
.w-3\/4 {
  width: calc(3 / 4 * 100%);
}

We also have some precedence for the % value as well, e.g. via-10% for gradient color stops.

I think I would personally towards the auto-rows-75% value instead of auto-rows-3/4. The fraction syntax works great for aspect ratio because that's literally what it is (aspect-16/9). The fraction also works great for widths, because you typically have 2 elements next to each other:

<div>
  <div class="w-1/3"></div>
  <div class="w-2/3"></div>
</div>

Since you only use the auto-rows-* once on a parent element, I think the auto-rows-75% makes a bit more sense than auto-rows-3/4 since there is no other element (at least not that I can think of).

TODO

  • Support percentages?
    • Syntax A: auto-rows-3/4
    • Syntax B: auto-rows-75%
    • Syntax C: support both, but that seems silly

Percentage support isn't a blocker for this PR, since you can always use auto-rows-[75%] if you want

Test plan

  1. Added a test to prove that this works
  2. Existing tests still pass

Requested by: #20225

@RobinMalfait RobinMalfait marked this pull request as ready for review June 12, 2026 15:25
@RobinMalfait RobinMalfait requested a review from a team as a code owner June 12, 2026 15:25
@greptile-apps

greptile-apps Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

Small, well-contained addition that follows the established spacing utility pattern exactly — safe to merge.

The bare-value handler uses the correct validator (isValidSpacingMultiplier) and properly guards on --spacing being present in the theme before emitting a value, which is identical to how every other spacing utility (w-*, h-*, m-*, etc.) is implemented. The test snapshots confirm correct CSS output and the change touches only the two target utilities.

No files require special attention.

Reviews (3): Last reviewed commit: "use `isValidSpacingMultiplier`" | Re-trigger Greptile

Comment thread packages/tailwindcss/src/utilities.ts
Comment thread packages/tailwindcss/src/utilities.ts
@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 1e4d2e72-d045-491d-a26e-678b456bda53

📥 Commits

Reviewing files that changed from the base of the PR and between be845eb and 28447f5.

📒 Files selected for processing (3)
  • CHANGELOG.md
  • packages/tailwindcss/src/utilities.test.ts
  • packages/tailwindcss/src/utilities.ts
✅ Files skipped from review due to trivial changes (1)
  • CHANGELOG.md
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/tailwindcss/src/utilities.test.ts
  • packages/tailwindcss/src/utilities.ts

Walkthrough

This PR introduces support for bare numeric spacing values in auto-cols-* and auto-rows-* utilities. The implementation adds handleBareValue handlers to both utilities in utilities.ts that accept positive integers and emit --spacing(<value>) calculations when theme resolution does not provide a value. Tests are updated to verify the feature works with a custom theme spacing token, and a changelog entry documents the addition.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: adding bare value support for auto-rows-* and auto-cols-* utilities, which is the primary objective of the changeset.
Description check ✅ Passed The description clearly explains the changes, provides context about previous functionality, shows concrete examples of the new feature, and discusses future considerations with a test plan.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

We expect that `auto-cols-12` and `auto-rows-12` will compile using the spacing scale.
This is more consistent with other places where we use the spacing scale
@RobinMalfait RobinMalfait force-pushed the feat/allow-spacing-values-in-auto-rows-cols branch from be845eb to 28447f5 Compare June 15, 2026 15:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant