# Spacing

Spatial rhythm, border radius, and layering conventions that keep the interface consistent.

## Base units

Two base units define the spatial rhythm. Components multiply these for padding, gaps, and margins.

- Horizontal 0.5rem Padding, gaps, and margins along the inline axis
- Vertical 0.5rem Padding, gaps, and margins along the block axis

## Ramp

A mechanical ramp for one-off gaps. Reach for a role below first; use a ramp step only where no role fits.

- `--q-space-3xs` 0.125rem · 1.875px
- `--q-space-2xs` 0.25rem · 3.75px
- `--q-space-xs` 0.5rem · 7.5px
- `--q-space-sm` 0.75rem · 11.25px
- `--q-space-md` 1rem · 15px
- `--q-space-lg` 1.5rem · 22.5px
- `--q-space-xl` 2rem · 30px
- `--q-space-2xl` 3rem · 45px

## Roles

The recurring gaps, each a step on the ramp, so one rhythm runs through every panel, list and table. Group with space and tone before reaching for a hairline: `--q-gap-stack` between the blocks of a panel, `--q-gap-section` between panels.

- `--q-pad-panel-y` 0.75rem Inside a panel or card, top and bottom
- `--q-pad-panel-x` 1rem Inside a panel or card, sides
- `--q-gap-stack` 0.75rem Between the blocks inside a panel
- `--q-gap-section` 0.75rem Between panels, and around the page
- `--q-gap-inline` 0.625rem Between things on one line: chips, actions
- `--q-row-pad-y` 0.5rem A list or table row, top and bottom
- `--q-row-pad-x` 0.75rem A list or table row, sides
- `--q-control-pad-x` 0.75rem A button or chip, sides

## Border radius

- Control 0.375rem
- Panel 0.75rem
- Container 0.875rem

## Elevation layers

Stacking order for overlapping surfaces. Higher layers sit above lower ones.

- 0 Document flow
- 1 Hover/active elevations
- 100 Sticky headers
- 200 Dropdowns, sidebar menus
- 900 Dialog backdrop
- 1000 Dialog content
- 1100 Floating UI inside modal
- 1200 Tooltips
- 1300 Notifications
- 1400 Onboarding takeover

## Examples

### Example 1: The spacing roles in a panel

Panel padding around a stack of rows, chips an inline gap apart, and a section gap to the next panel.

```svelte
<div class="role-demo">
  <div class="demo-panel">
    <span class="demo-title">A panel</span>
    <div class="demo-row">a row</div>
    <div class="demo-row">a row</div>
    <div class="demo-chips">
      <span class="demo-chip">chip</span>
      <span class="demo-chip">chip</span>
    </div>
  </div>
  <div class="demo-panel">
    <span class="demo-title">Its neighbour</span>
    <div class="demo-row">a row</div>
  </div>
</div>
```

---

From the Qualia design guide: https://q-core-3b2732.gitlab.io/tokens/spacing. Every page as markdown: https://q-core-3b2732.gitlab.io/llms.txt
