> ## Documentation Index
> Fetch the complete documentation index at: https://www.beeq.design/llms.txt
> Use this file to discover all available pages before exploring further.

# Spacing

> BEEQ spacing defines the rhythm between elements, sections, and layouts using a shared 4px-based scale.

![BEEQ spacing overview - light mode](https://mintcdn.com/beeq/hgUwMulNnDymPSd1/foundations/images/spacing/spacing-overview-light.svg?fit=max\&auto=format\&n=hgUwMulNnDymPSd1\&q=85\&s=1b7716d8622c7034e126680b18de3462)

BEEQ spacing overview

Spacing controls how close elements feel, how clearly sections separate, and how easily users can scan an interface. BEEQ uses one shared spacing scale for padding, margin, and gaps so product layouts stay consistent across components and screens.

Use BEEQ spacing tokens instead of one-off pixel values. The scale gives designers and developers the same language for compact details, grouped content, and larger page regions.

***

## 4px grid system

BEEQ spacing is built from a 4px grid. Most values are multiples of 4px, which creates predictable alignment and helps layouts scale cleanly across viewports.

![BEEQ 4px spacing grid system - light mode](https://mintcdn.com/beeq/hgUwMulNnDymPSd1/foundations/images/spacing/spacing-grid-system-light.svg?fit=max\&auto=format\&n=hgUwMulNnDymPSd1\&q=85\&s=601e56dae8d1653900622aaf5ae306d5)

BEEQ 4px spacing grid system

The scale uses T-shirt naming from `xs3` through `xxl4`. Smaller values support tight relationships inside components, while larger values create separation between regions.

![BEEQ spacing tokens - light mode](https://mintcdn.com/beeq/hgUwMulNnDymPSd1/foundations/images/spacing/spacing-tokens-light.svg?fit=max\&auto=format\&n=hgUwMulNnDymPSd1\&q=85\&s=29ad09750c6db1a21896350533e85fe8)

BEEQ spacing tokens

***

## Spacing scale

The current BEEQ spacing scale is exposed as CSS custom properties and Tailwind spacing keys.
BEEQ defines spacing values in `rem` so layouts can scale with the root font size.
Pixel values are shown as the default equivalent, based on a `16px` root font size.

| Token | CSS variable | Tailwind key | Value |
| - | - | - | - |
| `xs3` | `--bq-spacing-xs3` | `xs3` | `0.125rem` / `2px` |
| `xs2` | `--bq-spacing-xs2` | `xs2` | `0.25rem` / `4px` |
| `xs` | `--bq-spacing-xs` | `xs` | `0.5rem` / `8px` |
| `s` | `--bq-spacing-s` | `s` | `0.75rem` / `12px` |
| `m` | `--bq-spacing-m` | `m` | `1rem` / `16px` |
| `l` | `--bq-spacing-l` | `l` | `1.5rem` / `24px` |
| `xl` | `--bq-spacing-xl` | `xl` | `2rem` / `32px` |
| `xxl` | `--bq-spacing-xxl` | `xxl` | `2.5rem` / `40px` |
| `xxl2` | `--bq-spacing-xxl2` | `xxl2` | `3.5rem` / `56px` |
| `xxl3` | `--bq-spacing-xxl3` | `xxl3` | `4rem` / `64px` |
| `xxl4` | `--bq-spacing-xxl4` | `xxl4` | `4.5rem` / `72px` |

The example below shows a representative subset of the spacing scale. Use the table above as the complete reference for the tokens available in BEEQ.

```css CSS icon="css" expandable theme={"theme":{"light":"one-light","dark":"night-owl"}}
.spacing-scale {
  display: grid;
  gap: var(--bq-spacing-m);
  max-width: 42rem;
}

.spacing-row {
  display: grid;
  grid-template-columns: 4rem 1fr 7.5rem;
  align-items: center;
  gap: var(--bq-spacing-m);
}

.spacing-value {
  text-align: end;
}

.spacing-bar--xs3 {
  inline-size: var(--bq-spacing-xs3);
}

.spacing-bar--xs {
  inline-size: var(--bq-spacing-xs);
}

.spacing-bar--m {
  inline-size: var(--bq-spacing-m);
}

.spacing-bar--l {
  inline-size: var(--bq-spacing-l);
}

.spacing-bar--xl {
  inline-size: var(--bq-spacing-xl);
}

.spacing-bar--xxl2 {
  inline-size: var(--bq-spacing-xxl2);
}

.spacing-bar--xxl4 {
  inline-size: var(--bq-spacing-xxl4);
}
```

```html HTML icon="html5" expandable theme={"theme":{"light":"one-light","dark":"night-owl"}}
<div class="spacing-scale" aria-label="Representative BEEQ spacing values">
  <div class="spacing-row">
    <strong>xs3</strong>
    <span class="spacing-bar spacing-bar--xs3"></span>
    <span class="spacing-value">0.125rem / 2px</span>
  </div>
  <div class="spacing-row">
    <strong>xs</strong>
    <span class="spacing-bar spacing-bar--xs"></span>
    <span class="spacing-value">0.5rem / 8px</span>
  </div>
  <div class="spacing-row">
    <strong>m</strong>
    <span class="spacing-bar spacing-bar--m"></span>
    <span class="spacing-value">1rem / 16px</span>
  </div>
  <div class="spacing-row">
    <strong>l</strong>
    <span class="spacing-bar spacing-bar--l"></span>
    <span class="spacing-value">1.5rem / 24px</span>
  </div>
  <div class="spacing-row">
    <strong>xl</strong>
    <span class="spacing-bar spacing-bar--xl"></span>
    <span class="spacing-value">2rem / 32px</span>
  </div>
  <div class="spacing-row">
    <strong>xxl2</strong>
    <span class="spacing-bar spacing-bar--xxl2"></span>
    <span class="spacing-value">3.5rem / 56px</span>
  </div>
  <div class="spacing-row">
    <strong>xxl4</strong>
    <span class="spacing-bar spacing-bar--xxl4"></span>
    <span class="spacing-value">4.5rem / 72px</span>
  </div>
</div>
```

***

## Using spacing in code

BEEQ exposes one spacing scale. Gap utilities do not use separate gap tokens; they use the same values as padding and margin.

| Use case | Example |
| - | - |
| CSS custom property | `padding: var(--bq-spacing-m);` |
| Tailwind padding | `p-m`, `px-l`, `py-xs` |
| Tailwind margin | `m-l`, `mt-xl`, `mb-xs2` |
| Tailwind gap | `gap-m`, `gap-xl` |
| Logical padding | `p-b-m`, `p-bs-xs`, `p-be-l`, `p-i-m` |
| Logical margin | `m-b-l`, `m-bs-m`, `m-be-xl`, `m-i-m` |

Use logical utilities for layouts that need to adapt to writing direction or avoid left/right assumptions. Use CSS custom properties when writing custom CSS outside Tailwind utility composition.

```css CSS icon="css" expandable theme={"theme":{"light":"one-light","dark":"night-owl"}}
.settings-panel {
  max-width: 34rem;
}

.settings-panel__content {
  display: grid;
  gap: var(--bq-spacing-xs);
}
```

```html HTML icon="html5" expandable theme={"theme":{"light":"one-light","dark":"night-owl"}}
<bq-card class="settings-panel">
  <div class="settings-panel__content">
    <h2>Workspace settings</h2>
    <p class="settings-panel__description">
      The card owns its internal padding. The content controls the smaller gap between related text.
    </p>
    <bq-button appearance="primary">Save changes</bq-button>
  </div>
</bq-card>
```

***

## Internal and external spacing

Internal spacing is the space inside an element or component. It usually uses smaller values because the content is related. External spacing is the space between elements, groups, or page regions. It usually uses larger values to create separation and improve scanability.

Component internals already use BEEQ spacing. When you build custom layouts, use the same scale so page-level rhythm matches the components inside it.

![Spacing inside and between components - light mode](https://mintcdn.com/beeq/hgUwMulNnDymPSd1/foundations/images/spacing/spacing-usage-overview-light.svg?fit=max\&auto=format\&n=hgUwMulNnDymPSd1\&q=85\&s=121f529ad46aae05a6aee094a90be663)

Spacing inside and between components

```css CSS icon="css" expandable theme={"theme":{"light":"one-light","dark":"night-owl"}}
.layout-example {
  display: grid;
  gap: var(--bq-spacing-xl);
  max-width: 42rem;
}

.layout-card__content {
  display: grid;
  gap: var(--bq-spacing-xs);
  padding: var(--bq-spacing-m);
}
```

```html HTML icon="html5" expandable theme={"theme":{"light":"one-light","dark":"night-owl"}}
<div class="layout-example">
  <bq-card type="minimal">
    <article class="layout-card__content">
      <h2>Account health</h2>
      <p>Small internal gaps keep title and description connected.</p>
    </article>
  </bq-card>
  <bq-card type="minimal">
    <article class="layout-card__content">
      <h2>Billing status</h2>
      <p>The larger external gap separates this card from the previous region.</p>
    </article>
  </bq-card>
</div>
```

***

## Usage guidelines

> [accordion] Use the BEEQ scale
>
> Choose spacing values from the BEEQ scale instead of arbitrary pixels. This keeps layout rhythm aligned with components and design tokens.

> [accordion] Group related content with smaller spacing
>
> Use smaller values such as `xs`, `s`, and `m` for labels, descriptions, icon-text pairs, and content that belongs together.

> [accordion] Separate regions with larger spacing
>
> Use larger values such as `l`, `xl`, `xxl`, and above to separate cards, panels, sections, and page regions.

> [accordion] Keep vertical rhythm consistent
>
> Use repeated spacing decisions for similar content patterns. Consistent rhythm makes pages easier to scan and reduces visual noise.

> [accordion] Use logical spacing utilities
>
> Prefer utilities such as `p-b-m`, `p-i-m`, `m-b-l`, and `m-i-l` when spacing should follow block and inline directions instead of physical top, right, bottom, and left.

> [accordion] Avoid arbitrary values
>
> Avoid values like `10px`, `18px`, or `30px` unless there is a clear exception. Custom values make interfaces harder to align and maintain.

***

## Resources

> [card] [Global CSS variables](https://www.beeq.design/theming/global-css-variables.md)
>
> Review the spacing custom properties used by BEEQ themes.

> [card] [Spacing token source](https://github.com/Endava/BEEQ/blob/main/packages/beeq/src/global/styles/foundations/themes/beeq.scss)
>
> See the source that defines the BEEQ spacing scale.


## Related topics

- [Global CSS Variables](https://www.beeq.design/theming/global-css-variables.md)
- [Grid](https://www.beeq.design/foundations/grid.md)
- [Breadcrumb](https://www.beeq.design/components/breadcrumb.md)
- [Stroke](https://www.beeq.design/foundations/stroke.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.