CSS Generators

Spacing & Gap

All tools

Turn one spacing value into consistent stack, row and padding classes.

How it works

Four simple steps

1

Enter the spacing

Type the gap in pixels you want to standardise on.

2

Review the classes

Get .stack, .row and .pad using that same value.

3

Rename if needed

Add a suffix such as -sm or -lg when you create several sets.

4

Copy the utilities

Copy the classes or download spacing.css.

Spacing & Gap

About Spacing & Gap

Every form in the admin panel uses slightly different spacing between fields: 12 px here, 15 px there, margin-bottom somewhere else. You want one value applied everywhere through a couple of tiny classes. Type the value and copy them.

Enter a gap in pixels (the default is 16). The tool produces three one-line classes. .stack is a flex column with that gap, for vertical lists of fields, cards or paragraphs. .row is a flex row with the same gap, for button groups and inline controls. .pad applies the value as padding on all sides. All three update together, so your vertical rhythm, horizontal spacing and inner padding stay in step.

Using gap instead of margins on the children has a practical advantage: there is no stray margin after the last item, and you do not need :last-child overrides. If the row needs to wrap on small screens, add flex-wrap: wrap to the copied .row rule, since it is not included. Many teams generate two or three of these sets (for example 8, 16 and 32) and suffix the class names. To express the value in rem instead, run it through the px and rem converter. For alignment and direction options beyond a plain stack, use the visual flexbox generator.

The classes are rebuilt instantly as you change the number.

Keyboard shortcut

Ctrl Enter - Run tool
FAQ

Frequently asked questions

See all FAQs

Answers for this tool. For site-wide help, open the FAQ hub.

No. The output covers gap for stacks and rows and padding for containers. Gap usually replaces margins between siblings, which is why margin classes are not included.

Yes. They are independent flex containers, so a vertical stack can sit inside a horizontal row and each keeps its own gap.

The input is in pixels because that is how most design files are measured. Convert the number to rem if you want spacing to scale with the user's font size.

View more FAQs

Related tools

View all

Tailwind Class Sorter

Sort Tailwind classes and detect conflicting utilities with a winner explanation.

Open

Design System Diff Lab

Diff design tokens and inspect CSS @layer order and selector specificity locally.

Open

SVG Path Inspector

Parse SVG path commands, preview on canvas, round and minify coordinates.

Open

Flexbox Generator

Build flex layouts visually.

Open

Explore 321 free tools

Everything you need as a developer, marketer or creator - in one beautiful place.

Browse all tools