facebook / facebook/astryx

Add a Container layout primitive (centered max-width column with responsive gutters) — no current primitive covers it; Section doesn't center and only takes discrete padding

Open
#3,492 1 comment 0 reactions 0 assignees View on GitHub
component enhancement needs-scoping
Dominant language
TypeScript
Stars
13k
Forks
1.1k
Avg merge
1d 15h
Merged PRs (30d)
690

Description

### Summary

There's no Astryx primitive for the **centered, max-width content column with responsive side gutters** — the wrapper almost every page/section needs. `Section` sets a `max-width` but doesn't center (no `margin-inline: auto`) and only takes **discrete** spacing-step padding (no fluid gutter); `Center` centers content but has no max-width/gutter. So consumers fall back to a hand-rolled `

` + CSS, which is exactly what we ended up doing.

### What's missing

The canonical "page container": `max-width` + horizontal centering + a **fluid** side gutter that shrinks on small screens. Every mainstream system ships this — Tailwind (`container`), MUI (``), Chakra (``), Radix Themes (``). Astryx has the pieces (`Section`, `Center`) but not this combination.

### What we do today (the workaround)

```tsx
// modules/brutalbit/components/primitives.tsx
export function BBContainer({ children, style }) {
return

{children}
;
}
```
```css
.container {
max-width: 1280px;
margin-inline: auto; /* Section doesn't center */
padding-inline: clamp(20px, 4vw, 40px); /* Section padding is discrete steps, not fluid */
position: relative;
}
```

### Why `Section` doesn't cover it

- **No centering.** `Section maxWidth={1280}` compiles to `max-width: var(--x-maxWidth)` with no `margin-inline: auto`, so it pins width but hugs the left edge.
- **No fluid gutter.** `padding` accepts only spacing steps (`0 … 10`), so a `clamp(20px, 4vw, 40px)` gutter isn't expressible without a `style` override.
- **Wrong semantics for a wrapper.** `Section` renders a `` and is documented to "escape parent padding for edge-to-edge fills" — undesirable when you just want a neutral centered column, especially nested inside your own `` tags.

Faking it as `` is `Section` + two overrides doing the div's job — no cleaner than the div.

### Proposed

A `Container` primitive:

```tsx
{/* centers + fluid side padding */}

```

- Centers via `margin-inline: auto`.
- `maxWidth` (number | token).
- Responsive gutter driven by tokens (or a `gutter` scale), so it's theme-controlled rather than hard-coded per app.
- Neutral element (`

` by default, `as` to override), no edge-to-edge padding escaping.

### Environment

- `@astryxdesign/core@0.1.2`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.