# Container sizes

Preset lengths for width, height, minimum and maximum sizes.

- ID: tokens/container
- Type: tokens
- Canonical: /reference/tokens/container
- Version: 2.1.8
- Source revision: 09fc2350ea80ed137ba7ca62c8e5926744b5a5dc (revision)
- Source: packages/preset/src/theme.css
- Content digest: 8bef653b4173ba232e215d2a03acc6fb1287b2f01ff274eb3543bc00338f17e9
- Semantic digest: 83962260d6d56817dd052d2beebf7999a75804215dac050c47b26353145c099a
- Language: en

<a id="consumers"></a>

## Classes

| Class | Property | Declarations |
| --- | --- | --- |
| [`max-w-<name>`](/reference/tokens/families#family-max-w) | `max-width` | `max-width: var(--container-<name>)` |
| [`w-<name>`](/reference/tokens/families#family-w) | `width` | `width: var(--container-<name>)` |
| [`h-<name>`](/reference/tokens/families#family-h) | `height` | `height: var(--container-<name>)` |
| [`basis-<name>`](/reference/tokens/families#family-basis) | `flex-basis` | `flex-basis: var(--container-<name>)` |
| [`max-h-<name>`](/reference/tokens/families#family-max-h) | `max-height` | `max-height: var(--container-<name>)` |
| [`min-h-<name>`](/reference/tokens/families#family-min-h) | `min-height` | `min-height: var(--container-<name>)` |
| [`min-w-<name>`](/reference/tokens/families#family-min-w) | `min-width` | `min-width: var(--container-<name>)` |
| [`size-x-<name>`](/reference/tokens/families#family-size-x) | `inline-size` | `inline-size: var(--container-<name>)` |
| [`size-y-<name>`](/reference/tokens/families#family-size-y) | `block-size` | `block-size: var(--container-<name>)` |
| [`max-size-x-<name>`](/reference/tokens/families#family-max-size-x) | `max-inline-size` | `max-inline-size: var(--container-<name>)` |
| [`max-size-y-<name>`](/reference/tokens/families#family-max-size-y) | `max-block-size` | `max-block-size: var(--container-<name>)` |
| [`min-size-x-<name>`](/reference/tokens/families#family-min-size-x) | `min-inline-size` | `min-inline-size: var(--container-<name>)` |
| [`min-size-y-<name>`](/reference/tokens/families#family-min-size-y) | `min-block-size` | `min-block-size: var(--container-<name>)` |

Container tokens set lengths; they do not define viewport or container queries. Full and intrinsic sizes such as `w-full`, `max-w-fit` and `basis-min` are fixed utilities, independent of these tokens.

<a id="values"></a>

## Values

Each value is a length consumed by sizing properties. Pixel equivalents assume a 16px root font size. These are not viewport breakpoints or container-query definitions.

| Class | Variable | Value |
| --- | --- | --- |
| `max-w-3xs` | `--container-3xs` | `16rem` |
| `max-w-2xs` | `--container-2xs` | `18rem` |
| `max-w-xs` | `--container-xs` | `20rem` |
| `max-w-sm` | `--container-sm` | `24rem` |
| `max-w-md` | `--container-md` | `28rem` |
| `max-w-lg` | `--container-lg` | `32rem` |
| `max-w-xl` | `--container-xl` | `36rem` |
| `max-w-2xl` | `--container-2xl` | `42rem` |
| `max-w-3xl` | `--container-3xl` | `48rem` |
| `max-w-4xl` | `--container-4xl` | `56rem` |
| `max-w-5xl` | `--container-5xl` | `64rem` |
| `max-w-6xl` | `--container-6xl` | `72rem` |
| `max-w-7xl` | `--container-7xl` | `80rem` |
| `max-w-8xl` | `--container-8xl` | `90rem` |

<a id="size-limits"></a>

## A maximum is an upper bound

`max-w-3xs` sets `max-width: var(--container-3xs)`, whose preset value is `16rem`. An ordinary block with auto width can be narrower when its containing block has less room.

**The same maximum can produce different widths**

A normal block with auto width fits the available space up to its maximum. The two parent widths are drawn at the same scale, with a 16px root font size.

- max-w-3xs reads the preset --container-3xs value of 16rem. Both examples have auto width in normal block layout, use border-box sizing and have no minimum-width constraint.
- The first parent provides 20rem. The child stops at its 16rem maximum, leaving unused space after it.
- The second parent provides 13rem. The child fits that smaller space instead of becoming 16rem wide.
- The dashed contour identifies the available width; it is not a generated border or query container. Both parents are drawn at the same scale with a 16px root font size. Heights follow the same content.

`w-3xs` instead sets the width. Neither class adds centering, padding or query containment. Changing `--container-md` does not redefine `@container(--md)` or an explicit query threshold. Use native `container-type` and `container-name` when establishing a query container.

The native layout still matters: minimum sizes, box sizing, Flexbox and Grid can affect the used size. A maximum does not change text-wrapping or overflow rules. For a page wrapper and responsive layout decisions, continue with the Layout guide.

See [named query conditions](/reference/rules/named-conditions) and [container query grammar](/reference/rules/conditions#containersize) and [native sizing rules](https://www.w3.org/TR/css-sizing-3/#sizing-properties).

<a id="usage"></a>

## Usage

Cap a dialog and the measure of its text.

```html
<div class="… max-w-xs">
  <p>Leave this page?</p>
  <p class="… max-w-3xs">Changes you made will not be saved.</p>
</div>
```

```css disclosure=generated-css
@layer theme{:root,:host{--container-3xs:16rem;--container-xs:20rem}}@layer utilities{.max-w-3xs{max-width:var(--container-3xs)}.max-w-xs{max-width:var(--container-xs)}}
```

<a id="customize"></a>

## Customize

Change a preset value or add a size: `--container-prose` creates `max-w-prose`, `w-prose` and the other size classes.

```css
@theme {
  --container-prose: 40rem;
}
```

```css disclosure=generated-css
@layer theme{:root,:host{--container-prose:40rem}}@layer utilities{.max-w-prose{max-width:var(--container-prose)}}
```

See [theme directives](/reference/directives/theme) and [Layout](/guide/layout-system#use-container-tokens).

## Related reference

- [rules/modes](/reference/rules/modes.md)
- [directives/theme](/reference/directives/theme.md)
