Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions src/docs/responsive-design.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ Learn more about arbitrary value support in the [arbitrary values](/docs/adding-

### Basic example

Use the `@container` class to mark an element as a container, then use variants like `@sm` and `@md` to style child elements based on the size of the container:
Use the `@container` class to mark an element as an inline-size container, then use variants like `@sm` and `@md` to style child elements based on the size of the container:

```html
<!-- [!code filename:HTML] -->
Expand Down Expand Up @@ -444,6 +444,23 @@ For complex designs that use multiple nested containers, you can name containers

This makes it possible to style something based on the size of a distant container, rather than just the nearest container.

### Using size containers

Use `@container-size` to mark an element as a size container instead of an inline-size container when you need to use container query length units that depend on the block size, like `cqb`:

```html
<!-- [!code filename:HTML] -->
<!-- [!code word:@container-size] -->
<!-- [!code word:h-\[50cqb\]] -->
<div class="@container-size">
<div class="h-[50cqb]">
<!-- ... -->
</div>
</div>
```

You can also name size containers using `@container-size/{name}`.

### Using custom container sizes

Use the `--container-*` theme variables to customize your container sizes:
Expand Down Expand Up @@ -491,18 +508,20 @@ Use variants like `@min-[475px]` and `@max-[960px]` for one-off container query

### Using container query units

Use [container query length units](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_containment/Container_queries#container_query_length_units) like `cqw` as arbitrary values in other utility classes to reference the container size:
Use [container query length units](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_containment/Container_queries#container_query_length_units) like `cqw` and `cqi` as arbitrary values in other utility classes to reference the container size:

```html
<!-- [!code filename:HTML] -->
<!-- [!code word:w-\[50cqw\] -->
<!-- [!code word:w-\[50cqw\]] -->
<div class="@container">
<div class="w-[50cqw]">
<!-- ... -->
</div>
</div>
```

For units that need more than the inline size, like `cqb` and `cqh`, use `@container-size` to make the full size of the container available.

### Container size reference

By default, Tailwind includes container sizes ranging from 16rem _(256px)_ to 80rem _(1280px)_:
Expand Down