Container

The one content edge: every page's width and side padding.

Overview

Content outside an AppShell, such as a band in a bleed shell, that must start at the same x as the page.

One edge

Do

Plan

Team, billed monthly.
import { Body, Card, Container } from "@hackcove/ui";

<Container as="section" aria-label="Billing">
  <Card title="Plan">
    <Body>Team, billed monthly.</Body>
  </Card>
</Container>
One Container is the content edge: everything inside it starts at the same x.
Don't

Plan

Team, billed monthly.
import { Body, Card, Container } from "@hackcove/ui";

<Container as="section" aria-label="Billing">
  <Container>
    <Card title="Plan">
      <Body>Team, billed monthly.</Body>
    </Card>
  </Container>
</Container>
A Container inside a Container pads the content twice, so it no longer lines up with the page. AppShell already wraps its main in one.

Usage

  • Container is the only place the page width (max-w-6xl) and side padding are defined; a header, a page and a footer inside one start at the same x.
  • AppShell already wraps its header, main and footer in one. Use Container only for a part of a bleed shell that spans the page, so its content still keeps the edge.
  • Never nest a Container in a Container: the padding doubles.
  • as picks the element: div (default), main, header, footer, section or nav. A section or nav needs an aria-label.
  • Space inside it with a Stack; a Container has no vertical padding or gap of its own.

Accessibility

  • A Container adds no role: a div is not a landmark. as picks main, header, footer, section or nav when the part should be one.
  • aria-* and data-* go on the rendered element.

API

Container

The one content edge: every page's width and side padding. This file is the only place they are defined, so a header, a page and a footer inside a Container start at the same x.


as
Type
"nav" | "header" | "footer" | "main" | "div" | "section"

elementRef

The rendered element, for a parent that measures or scrolls it.

Type
((element: HTMLElement | null) => void)