tailwindcss.com
tailwindcss.com copied to clipboard
Spacing Scale
The docs refer to spacing scale all over the place but I can find no mention of what the default spacing scale is or how to customize it.
This is quite frustrating as how am I supposed to know what numbers should work/what numbers are included in the spacing scale?
Good catch, lot of stuff that was written for v3 when there was an explicit spacing scale that is kinda confusing now that everything is driven by a single --spacing multiplier variable in v4 by default.
The best reference right now is the v4 beta documentation:
https://v3.tailwindcss.com/docs/v4-beta#dynamic-spacing-scale
I'll make sure we get a dedicated spacing page added to the theme documentation though that talks about this.
I appreciate the notion to centralize on a "spacing" attribute. When you build the page it can have a way to reference the size needed in a lookup fashion?
I do a lot of converting between handwritten CSS and tailwind, and the table which looked like this was very handy:
Class | Properties |
|---|---|
| w-0 | width: 0px; |
| w-px | width: 1px; |
| w-0.5 | width: 0.125rem; /* 2px */ |
| w-1 | width: 0.25rem; /* 4px */ |
I could take a value, like 201px or 19rem and scan down the right side of the table to find the closest matching utility class. I do this all the time. At the moment I'm just using the v3 pages for this, and it's working fine.