Layout & Spacing
Structural patterns for page composition, container sizing, and the standard page template.
Container Widths
Three container widths cover all content scenarios. Use the narrowest option that fits the content.
| Width | Tailwind | Pixels | Usage |
|---|---|---|---|
| Narrow | max-w-3xl | 768px | Card grids, focused content |
| Default | max-w-4xl | 896px | Standard page content |
| Wide | max-w-5xl | 1024px | Dashboards, wide tables |
Page Template
Every page in the ONCE site follows this skeleton. The Navbar and Footer are always present; only the inner content changes.
const PageName = () => {
return (
<main className="min-h-screen bg-once-bg">
<Navbar />
{/* Page content */}
<Footer />
</main>
);
};Key rules
- Background is always
bg-once-bg(#070D19) for the outermost wrapper min-h-screenensures the page fills the viewport even when content is short- Navbar and Footer are shared components — never inline their markup
Section Spacing
Content sections are separated with consistent vertical rhythm:
| Element | Margin | Notes |
|---|---|---|
Section (h2) | margin-top: 36px | Plus a top border for visual separation |
Subsection (h3) | margin-top: 28px | No border |
| Card grid | margin: 24px 0 | Between content blocks and grids |
| Divider | margin: 40px 0 | Full-width horizontal rule |
| Info box | margin: 24px 0 | Callout blocks between paragraphs |
Grid Patterns
Card Grid
The standard card layout uses CSS Grid with auto-fit to adapt from one column on mobile to multiple columns on wider screens:
.card-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
gap: 12px;
margin: 24px 0;
}No breakpoint media queries needed — the minmax function handles responsive behavior.
Two-Column Layout
For side-by-side content (e.g., a preview alongside code), use a simple flex row:
<div style={{ display: 'flex', gap: '24px', alignItems: 'flex-start' }}>
<div style={{ flex: 1 }}>{/* Content */}</div>
<div style={{ flex: 1 }}>{/* Preview */}</div>
</div>On mobile, let flex items wrap naturally or switch to a single column with a media query.
Docs Navigation Width
The documentation site (Nextra) constrains the main nav to 64rem (1024px):
.nextra-nav-container nav {
max-width: 64rem !important;
}Sidebar collapse is set at level 2 by default, keeping section groups open while their children start collapsed.