LayoutContainer
Searchastronomic.dev# Container
To keep page content to a readable width with even side padding, centered on the page.
Static: no JavaScript.
## Usage
```astro
import Container from "@astronomic-dev/ui/components/Container.astro";
```
## Examples
### Page width
The content keeps to the size's width and the side padding.
```astro
---
import Container from "@astronomic-dev/ui/components/Container.astro";
---
<div class="bg-surface-2 py-6">
<Container>
<div class="grid gap-2 rounded-card bg-surface p-6">
<p class="m-0 font-semibold">Halden Studio</p>
<p class="m-0 max-w-[60ch] text-muted">Brand and web design for small firms. This text keeps to the page width, with the same padding on both sides.</p>
</div>
</Container>
</div>
```
### Sizes
sm suits a column of text; lg is a page.
```astro
---
import Container from "@astronomic-dev/ui/components/Container.astro";
const sizes = ["sm", "md", "lg"] as const;
---
<div class="grid gap-3 bg-surface-2 py-6">
{
sizes.map((size) => (
<Container size={size}>
<p class="m-0 rounded-card bg-surface p-4 text-sm text-muted">size="{size}"</p>
</Container>
))
}
</div>
```
## Props
### Container
| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `as` | `HTMLTag` | `"div"` | The element to render, such as main or header. |
| `size` | `"sm" \| "md" \| "lg" \| "full"` | `"lg"` | The max width: `sm` 42rem, `md` 64rem, `lg` 80rem, `full` none. Centered when narrower than the page. |
| `class` | `string` | None | More classes, merged with cn(), so yours win on conflicts. |
| Slot | Description |
| --- | --- |
| `default` | The content. |
Any other attribute goes on the rendered element.
## Accessibility
- Renders a plain <div> with no role, so it adds nothing for a screen reader.
- Use as="main" for the page's main content, so it is a landmark; give the page only one.
Container
FreeTo keep page content to a readable width with even side padding, centered on the page.
- File
- Container.astro
- Group
- Layout
- Kind
- Static: no JavaScript
- Examples
- 2
Examples
Drag the orange handle to set the width. Frames get real breakpoints.
- Static
- Interactive
- Framed
Page width
The content keeps to the size's width and the side padding.
This preview did not load.
main.astro
examples/container/main.astro
---
import Container from "@astronomic-dev/ui/components/Container.astro";
---
<div class="bg-surface-2 py-6">
<Container>
<div class="grid gap-2 rounded-card bg-surface p-6">
<p class="m-0 font-semibold">Halden Studio</p>
<p class="m-0 max-w-[60ch] text-muted">Brand and web design for small firms. This text keeps to the page width, with the same padding on both sides.</p>
</div>
</Container>
</div>Sizes
sm suits a column of text; lg is a page.
This preview did not load.
sizes.astro
examples/container/sizes.astro
---
import Container from "@astronomic-dev/ui/components/Container.astro";
const sizes = ["sm", "md", "lg"] as const;
---
<div class="grid gap-3 bg-surface-2 py-6">
{
sizes.map((size) => (
<Container size={size}>
<p class="m-0 rounded-card bg-surface p-4 text-sm text-muted">size="{size}"</p>
</Container>
))
}
</div>Minimal · Light