> A guide to [@fabiocv/ui](https://ui.fabio.cv/). Every guide is listed at https://ui.fabio.cv/llms.txt.

# Spacing

A line of text is 24px tall, and vertical space is built from that.

## Rules

- Stack lines inside a block with no gap between them.
- Put a section heading one line above its content, using `Spacing[24]`.
- Put sections 48px apart on tablet and desktop, and 32px apart on mobile.
- Start a page's content 48px below the top bar, at every size.
- Put 80px between page content and the footer on tablet and desktop.
- Make every gap a token or a whole number of grid columns. No one-off values.
- Measure padding and gaps to an icon's 16px drawing area, not its 24px box. The 4px of air on each side counts toward the space beside it, so an icon sits as far from its neighbours as text does.
- Line labels up with the text around them, not the box they sit in. A `Button` or a list's hover box in a column of text reaches `8px` past it on each side: `marginInline: calc(${Spacing[8]} * -1)`.
- `Spacing` values are CSS variables, so the inspector shows the token. Do maths with `calc()` and never append `px`.

## Tokens

| Token                   | Value   | Code                | Use for                                                                                                                     | On fabio.cv                                                                                                        |
| ----------------------- | ------- | ------------------- | --------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------ |
| `--spacing-2`           | `2px`   | `Spacing[2]`        | The padding of menus and toggle tracks, and of a drawer's sheet                                                             |                                                                                                                    |
| `--spacing-grid-gutter` | `4px`   | `Grid.Gutter`       | The gutter of the 24-column grid, and a menu's gap from its trigger                                                         | Between client tiles, work columns and modal images                                                                |
| `--spacing-8`           | `8px`   | `Spacing[8]`        | Compact inline spacing: a control's horizontal padding, the gap between an icon and its label, and a notched menu separator | Between the footer's link lines and the top bar's trail steps, and how far the writing hover reaches past its text |
| `--spacing-12`          | `12px`  | `Spacing[12]`       | The gap between a menu item's leading icon and its label                                                                    |                                                                                                                    |
| `--spacing-16`          | `16px`  | `Spacing[16]`       | Mobile viewport edges and top content inset, an icon's drawing area, and a tooltip's distance from the pointer              | How far a client logo takes the pointer past its edges                                                             |
| `--spacing-24`          | `24px`  | `Spacing[24]`       | One line of text: rows, section headings, the space under them, an icon's box and compact buttons                           | The header menu button, the space between footer links and the top bar's distance from the top of the page         |
| `--spacing-32`          | `32px`  | `Spacing[32]`       | Mobile section gaps, buttons, menu items, toggles and tags                                                                  | The footer's mobile group gap and desktop writing rows                                                             |
| `--spacing-48`          | `48px`  | `Spacing[48]`       | Desktop and tablet section gaps, a page's gap below the top bar, and a drawer's distance from the top on a phone            | Mobile footer padding and modal text padding                                                                       |
| `--spacing-80`          | `80px`  | `Spacing[80]`       | Between desktop or tablet page content and the footer                                                                       |                                                                                                                    |
| `--spacing-96`          | `96px`  | `Spacing[96]`       | A drawer's distance from the top, from tablet up                                                                            | The tablet footer's bottom inset                                                                                   |
| `--spacing-page-block`  | `150px` | `Spacing.PageBlock` |                                                                                                                             | The footer's bottom inset on desktop                                                                               |

A block of several lines is a multiple of the line: a tile four lines tall is `calc(${Spacing[24]} * 4)`.

See it at https://ui.fabio.cv/spacing/.
