# Layout (https://divplate.com/docs/layout)



`Section` sets the space above and below a block, and `Container` sets how
wide it gets. Both read tokens, so you can change one value and every block
follows.

## Spacing [#spacing]

| Value            | What it does                                                          |
| ---------------- | --------------------------------------------------------------------- |
| `default`        | 64px above and below, 96px from `md`, 128px from `lg`                 |
| `compact`        | 64px at every width                                                   |
| `flush`          | The default space above, nothing below                                |
| `viewport`       | Fills the screen from `lg` up and centers its content                 |
| `viewport-flush` | `viewport` from `lg` up, `flush` below                                |
| `rising`         | Fills the screen from `lg` up, content at the top; `flush` below `lg` |
| `closing`        | For the last section on a page: 64px above, 20px below                |
| `bar`            | For a one-row footer: 32px above, 20px below                          |
| `none`           | No space at all                                                       |

### viewport [#viewport]

Made for the first block on a page. From `lg` up it is as tall as the screen
and centers its content. Below `lg` it behaves like `default`.

If your site has a fixed header, set `--viewport-offset` to the header's
height, so the section does not run past the bottom of the screen:

```tsx title="app/layout.tsx"
<main className="pt-header [--viewport-offset:var(--spacing-header)]">
  {children}
</main>
```

<Callout>
  The space is uneven on purpose, 64px above and 128px below. Content sits a
  little high that way, which is where centered looks centered.
</Callout>

## The spacing values [#the-spacing-values]

These three set the default spacing. Change them and every block follows:

```css
@theme {
  --spacing-section: 4rem; /* mobile  */
  --spacing-section-md: 6rem; /* from md */
  --spacing-section-lg: 8rem; /* from lg */
}
```

`closing` and `bar` use `--spacing-section-close` and `--spacing-section-bar`,
which stay the same at every width.

## Width [#width]

`Container` caps the width of the page and keeps a margin on each side. It
takes one prop:

| `width`                      | Token                     | For                              |
| ---------------------------- | ------------------------- | -------------------------------- |
| `page&#x60; &#x2A;(default)* | `--container-page`, 79rem | Every block                      |
| `wide`                       | `--container-wide`, 90rem | Split blocks that need more room |

```css
@theme {
  --container-page: 79rem;
  --container-wide: 90rem;
  --spacing-gutter: clamp(1rem, 0.629rem + 1.524vw, 2rem);
}
```

The side margin is part of that width, so on a desktop the content is 1200px
wide.

<Callout title="Names to avoid">
  Never call a `--container-*` token `block`, `flex`, `grid` or `table`.
  Tailwind would also turn it into an `inline-*` class, so `--container-block`
  makes every `inline-block` on the page 79rem wide, with no error.
</Callout>

## Text widths [#text-widths]

The container caps the page. These cap a column of text:

| Token           | Width    | For                                       |
| --------------- | -------- | ----------------------------------------- |
| `max-w-copy`    | 48rem    | A centered text column                    |
| `max-w-measure` | 36rem    | The paragraph under a headline            |
| `max-w-blurb`   | 22rem    | A short line beside other columns         |
| `max-w-list`    | 45rem    | A list of rows, such as FAQ questions     |
| `max-w-body`    | 33.75rem | A normal paragraph, such as an FAQ answer |

## Corners [#corners]

Blocks round their corners with `rounded-sm` to `rounded-4xl`, seven steps
based on your project's `--radius`:

```css
@theme inline {
  --radius-sm: max(min(calc(var(--radius) - 10px), calc(var(--radius) * 0.4)), calc(var(--radius) * 0.25));
  --radius-md: max(calc(var(--radius) - 8px), calc(var(--radius) * 0.5));
  --radius-lg: var(--radius);
  --radius-xl: calc(var(--radius) + 8px);
  --radius-2xl: calc(var(--radius) + 16px);
  --radius-3xl: calc(var(--radius) + 24px);
  --radius-4xl: calc(var(--radius) + 32px);
}
```

Change `--radius` and they all follow. The previews use `1rem`.

<Callout title="Paste this one yourself">
  `shadcn init` writes its own version of these, and installing a block never
  overwrites variables you already have. Paste the block above to get the
  corners from the previews.
</Callout>

## Grid lines [#grid-lines]

Your page can show thin lines along the edges of the content and between
sections. Turn them on with attributes on the element around your page:

```tsx
<body data-rails="on" data-line-style="etched" data-line-opacity="strong">
```

| Attribute           | Values                     | Default  |
| ------------------- | -------------------------- | -------- |
| `data-rails`        | `on`                       | off      |
| `data-line-style`   | `line`, `dashed`, `etched` | `line`   |
| `data-line-opacity` | `low`, `normal`, `strong`  | `normal` |

Leave an attribute out to keep its default. Turning the lines on moves
nothing. The style and opacity also apply to the dividers inside cards.

### Snapping to the lines [#snapping-to-the-lines]

Some blocks have a second look that sits right on the lines, such as pricing
plans as cells. Pass `snap` to use it:

```tsx
<Pricing02 as="h2" snap />
```

In the page builder, it is the Snap to lines switch on a section.

<Callout>
  The lines use your text color, so they follow your theme and palette.
</Callout>
