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

We expect that `auto-cols-12` and `auto-rows-12` will compile using the spacing scale.
@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, self-contained addition that mirrors an established pattern throughout the file; no existing behavior is changed and new utilities silently no-op when --spacing is absent.

Both handlers follow the exact same guard-then-return pattern as spacingUtility. The --spacing presence check prevents spurious output in themes that omit the variable, and isValidSpacingMultiplier correctly allows decimal multipliers. Tests supply the required theme context and snapshot the expected output. No edge cases are left unhandled.

No files require special attention.

Reviews (2): 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: ca7f6106-e184-49a0-b5a7-200350c65904

📥 Commits

Reviewing files that changed from the base of the PR and between 15f6b56 and be845eb.

📒 Files selected for processing (1)
  • packages/tailwindcss/src/utilities.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • 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 clearly and concisely summarizes the main change: adding bare value support for auto-rows-* and auto-cols-* utilities, which is the core focus of the changeset.
Description check ✅ Passed The description is directly related to the changeset, providing detailed context about the feature, implementation approach, and test plan for adding bare value support to auto-rows-* and auto-cols-*.
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.

This is more consistent with other places where we use the spacing scale
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