tailwindcss.com icon indicating copy to clipboard operation
tailwindcss.com copied to clipboard

Spacing Scale

Open jonathan-wondereur opened this issue 8 months ago • 2 comments

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?

jonathan-wondereur avatar Feb 28 '25 17:02 jonathan-wondereur

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.

adamwathan avatar Feb 28 '25 17:02 adamwathan

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-0width: 0px;
w-pxwidth: 1px;
w-0.5width: 0.125rem; /* 2px */
w-1width: 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.

robacarp avatar Mar 12 '25 01:03 robacarp