<!-- index: /slotted/llms.txt -->
# container

`data-ui="container"` · Centers content at a maximum width.

## Minimal example

Example

```tsx
import { Badge } from '@slotted/react/badge';
import { Card, CardActions, CardHeader } from '@slotted/react/card';
import { Container } from '@slotted/react/container';
import { Stack } from '@slotted/react/stack';
import { Heading, Text } from '@slotted/react/typography';

export default function ContainerBasic() {
  return (
    <Container size="measure">
      <Stack gap={5}>
        <Heading level={2} size="md">
          Usage this month
        </Heading>
        <Text>
          Seats are billed per active user and settled with the invoice on the first business day of
          the next month. Archived warehouses stop counting from the day they are archived.
        </Text>
        <Card>
          <CardHeader>
            <Text weight="semibold">42 active seats</Text>
            <Text size="sm" tone="muted">
              $1,260.00 on December 1
            </Text>
            <CardActions>
              <Badge tone="info">Open</Badge>
            </CardActions>
          </CardHeader>
        </Card>
      </Stack>
    </Container>
  );
}
```

## Props

| Name | Type | Default | Applies to | Description |
| --- | --- | --- | --- | --- |
| `size` | `'measure' \| 'content' \| 'wide' \| 'full' \| 'bleed'` | content | Container | Names what the column is bounded to. measure is a reading line of 65ch, content is 56rem and wide is 80rem. full takes the space the frame gives, up to 120rem (--slotted-container-full). bleed removes the maximum. full and bleed keep the inset. |
| `inset` | `0 \| 1 \| … \| 12` | 6 | Container | Sets the minimum gap between the column and the edge of the space the container was given, as a step on the space scale. |
| `align` | `'center' \| 'start' \| 'end'` | center | Container | Sets where the column sits when space is left over. The value is logical, so a right-to-left document mirrors. |
| `render` | `(props) => ReactNode` | — | Container, ContainerBreakout | Renders a different root element from the props it receives. |

## Axes and defaults

| Axis | Values | Default |
| --- | --- | --- |
| `size` | `measure`, `content`, `wide`, `full`, `bleed` | `content` |
| `inset` | `0`, `1`, `2`, `3`, `4`, `5`, `6`, `7`, `8`, `9`, `10`, `11`, `12` | `6` |
| `align` | `center`, `start`, `end` | `center` |

## Rules

- Container has no role and no ARIA. It bounds what you write inside it, and the children keep whatever semantics they already had. Render a main, a section or an article through render so the document says what it means.
- size="measure" bounds the line at 65ch. WCAG 2.2 SC 1.4.8 asks for no more than 80 characters per line, and technique C20 asks that the width be set in a relative measurement; ch is relative to the inherited type, so the bound follows a reader who enlarges the text rather than fighting them.
- Every other step is stated in rem, so the whole page grows with the browser zoom WCAG SC 1.4.4 requires.
- The column collapses continuously through min(), and every child is allowed to shrink below its content, so a long unbroken token overflows its own box rather than widening the page — the two-axis scroll SC 1.4.10 refuses.
- Nothing reorders children. Visual order stays DOM order, which is what SC 1.3.2 asks for, and a breakout is read where it is written.
- The root is a grid, so a run of text written directly inside it becomes an item nothing can place in the column. Wrap text in an element.

## Tokens

`--slotted-container-content`, `--slotted-container-full`, `--slotted-container-measure`, `--slotted-container-wide`, `--slotted-space-1`, `--slotted-space-10`, `--slotted-space-11`, `--slotted-space-12`, `--slotted-space-2`, `--slotted-space-3`, `--slotted-space-4`, `--slotted-space-5`, `--slotted-space-6`, `--slotted-space-7`, `--slotted-space-8`, `--slotted-space-9`

## Examples

### A reading page holding a table that reaches both edges

Excerpt — not a complete module

```tsx
<Container render={(props) => <main {...props} />} size="measure">
  <Stack gap={6}>
    <Heading level={1}>Usage this month</Heading>
    <Text>Billed per seat, settled with the invoice.</Text>
  </Stack>
  <ContainerBreakout>
    <UsageTable />
  </ContainerBreakout>
  <Text>Bounded content resumes at the same column.</Text>
</Container>;
```

### Bounded content returns inside a breakout

Excerpt — not a complete module

```tsx
<Container size="measure">
  <Article />
  <ContainerBreakout style={{ background: 'var(--slotted-surface-sunken)' }}>
    <Container size="wide" inset={9}>
      <RelatedAccounts />
    </Container>
  </ContainerBreakout>
</Container>;
```

### An application decides once what its pages are bounded to

Excerpt — not a complete module

```tsx
<ContainerDefaultsProvider inset={8} size="wide">
  <App />
</ContainerDefaultsProvider>;
```

### A theme that retunes the maxima

Excerpt — not a complete module

```css
[data-slotted-theme='acme'] {
  --slotted-container-measure: 60ch;
  --slotted-container-content: 48rem;
  --slotted-container-wide: 90rem;
}
```

### align.tsx

Example

```tsx
import type { CSSProperties } from 'react';

import { Card, CardBody } from '@slotted/react/card';
import { Container } from '@slotted/react/container';
import { Stack } from '@slotted/react/stack';
import { Text } from '@slotted/react/typography';

const ALIGNS = ['center', 'start', 'end'] as const;

const MAXIMA = { '--slotted-container-measure': '40ch' } as CSSProperties;

export default function ContainerAlign() {
  return (
    <Stack gap={4} style={MAXIMA}>
      {ALIGNS.map((align) => (
        <Card key={align}>
          <Container align={align} size="measure">
            <Card>
              <CardBody>
                <Text>{`align: ${align}`}</Text>
              </CardBody>
            </Card>
          </Container>
        </Card>
      ))}
    </Stack>
  );
}
```

### breakout.tsx

Example

```tsx
import type { CSSProperties } from 'react';

import { Card, CardBody } from '@slotted/react/card';
import { Container, ContainerBreakout } from '@slotted/react/container';
import { Stack } from '@slotted/react/stack';
import { Heading, Text } from '@slotted/react/typography';

const COLUMN = {
  '--slotted-container-measure': '40ch',
  rowGap: 'var(--slotted-space-5)',
} as CSSProperties;

export default function ContainerBreakoutExample() {
  return (
    <Container size="measure" style={COLUMN}>
      <Stack gap={3}>
        <Heading level={2} size="md">
          Quarter-end stock count
        </Heading>
        <Text>
          Counts finished at 14 of 14 sites. Three sites report a variance above 2% and are listed
          below.
        </Text>
      </Stack>

      <ContainerBreakout>
        <Card>
          <CardBody>
            <Text>Singapore +2.4%, Chicago -3.1%, Osaka +2.2%. 41,926 units counted.</Text>
          </CardBody>
        </Card>
      </ContainerBreakout>

      <Text>The text returns to the same column after the breakout.</Text>
    </Container>
  );
}
```

### defaults.tsx

Example

```tsx
import type { CSSProperties } from 'react';

import { Card, CardBody } from '@slotted/react/card';
import { Container, ContainerDefaultsProvider } from '@slotted/react/container';
import { Stack } from '@slotted/react/stack';
import { Text } from '@slotted/react/typography';

const MAXIMA = { '--slotted-container-measure': '40ch' } as CSSProperties;

export default function ContainerDefaults() {
  return (
    <ContainerDefaultsProvider align="start" inset={9} size="measure">
      <Stack gap={4} style={MAXIMA}>
        <Card>
          <Container>
            <Card>
              <CardBody>
                <Text>Takes size, inset and align from the provider.</Text>
              </CardBody>
            </Card>
          </Container>
        </Card>

        <Card>
          <Container align="center" inset={3} size="wide">
            <Card>
              <CardBody>
                <Text>States its own size, inset and align.</Text>
              </CardBody>
            </Card>
          </Container>
        </Card>
      </Stack>
    </ContainerDefaultsProvider>
  );
}
```

### inset.tsx

Example

```tsx
import { Card, CardBody } from '@slotted/react/card';
import { Container } from '@slotted/react/container';
import { Stack } from '@slotted/react/stack';
import { Text } from '@slotted/react/typography';

const INSETS = [0, 3, 6, 12] as const;

export default function ContainerInset() {
  return (
    <Stack gap={4}>
      {INSETS.map((inset) => (
        <Card key={inset}>
          <Container inset={inset} size="bleed">
            <Card>
              <CardBody>
                <Text>{`inset: ${inset}`}</Text>
              </CardBody>
            </Card>
          </Container>
        </Card>
      ))}
    </Stack>
  );
}
```

### size.tsx

Example

```tsx
import type { CSSProperties } from 'react';

import { Card, CardBody } from '@slotted/react/card';
import { Container } from '@slotted/react/container';
import { Stack } from '@slotted/react/stack';
import { Text } from '@slotted/react/typography';

const SIZES = ['measure', 'content', 'wide', 'full', 'bleed'] as const;

const MAXIMA = {
  '--slotted-container-measure': '40ch',
  '--slotted-container-content': '28rem',
  '--slotted-container-wide': '34rem',
  '--slotted-container-full': '38rem',
} as CSSProperties;

export default function ContainerSize() {
  return (
    <Stack gap={4} style={MAXIMA}>
      {SIZES.map((size) => (
        <Container key={size} inset={0} size={size}>
          <Card>
            <CardBody>
              <Text>{size}</Text>
            </CardBody>
          </Card>
        </Container>
      ))}
    </Stack>
  );
}
```
