Skip to content

Layout

Spacing, width, corners and grid lines

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

ValueWhat it does
default64px above and below, 96px from md, 128px from lg
compact64px at every width
flushThe default space above, nothing below
viewportFills the screen from lg up and centers its content
viewport-flushviewport from lg up, flush below
risingFills the screen from lg up, content at the top; flush below lg
closingFor the last section on a page: 64px above, 20px below
barFor a one-row footer: 32px above, 20px below
noneNo space at all

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:

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

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

The spacing values

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

@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

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

widthTokenFor
page (default)--container-page, 79remEvery block
wide--container-wide, 90remSplit blocks that need more room
@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.

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.

Text widths

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

TokenWidthFor
max-w-copy48remA centered text column
max-w-measure36remThe paragraph under a headline
max-w-blurb22remA short line beside other columns
max-w-list45remA list of rows, such as FAQ questions
max-w-body33.75remA normal paragraph, such as an FAQ answer

Corners

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

@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.

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.

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:

<body data-rails="on" data-line-style="etched" data-line-opacity="strong">
AttributeValuesDefault
data-railsonoff
data-line-styleline, dashed, etchedline
data-line-opacitylow, normal, strongnormal

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

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

<Pricing02 as="h2" snap />

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

The lines use your text color, so they follow your theme and palette.