Container
A centred page-width wrapper with fluid and narrow widths.
The default is 87.5rem at most, narrow is 48rem and fluid has no limit. Padding is 16px, and 32px from 768px up. as picks the element.
Widths
Default: 87.5rem at most
Narrow: 48rem at most
Fluid: as wide as the page
import { Container } from "@/components/ui/container"
const widths = [
{ label: "Default: 87.5rem at most", fluid: false, narrow: false },
{ label: "Narrow: 48rem at most", fluid: false, narrow: true },
{ label: "Fluid: as wide as the page", fluid: true, narrow: false },
]
export default function ContainerWidths() {
return (
<figure className="flex flex-col gap-4 text-sm">
{widths.map(({ label, fluid, narrow }) => (
<div key={label} className="flex flex-col gap-1.5">
<span>{label}</span>
<div className="w-[96rem] bg-muted py-5 [zoom:0.2]">
<Container fluid={fluid} narrow={narrow}>
<div className="h-20 bg-foreground/20" />
</Container>
</div>
</div>
))}
<figcaption className="text-muted-foreground">Each band is a page 96rem wide, drawn at a fifth of its size.</figcaption>
</figure>
)
}
Reading column
Release 4.2
Invoices can be exported as PDF, task lists remember their sort order and the project switcher opens faster. The container centres this column, caps it at 48rem and keeps 16px of padding on a phone and 32px from the tablet width up.
import { Container } from "@/components/ui/container"
export default function ContainerReadingColumn() {
return (
<Container as="article" narrow className="flex flex-col gap-3">
<p className="text-lg">Release 4.2</p>
<p className="text-base text-muted-foreground">
Invoices can be exported as PDF, task lists remember their sort order and the project switcher opens faster.
The container centres this column, caps it at 48rem and keeps 16px of padding on a phone and 32px from the
tablet width up.
</p>
</Container>
)
}
Installation
npx shadcn@latest add @khaeli/containerbunx --bun shadcn@latest add @khaeli/containerInstall @khaeli/foundation first: this item's styling lives in its tokens and [data-slot] rules.
Installs with
- Registry items
Registry JSON
The item as the shadcn CLI reads it, with every file it ships: https://ui.khaeli.com/r/container.json