Section
A full-width page band with background and padding variants.
A band spans the full width, so put a @khaeli/container inside it to hold the content. as picks the element: section by default.
Backgrounds
Transparent, the default: the page shows through.
Light: the page background.
Muted: a quiet band between two plain ones.
Dark: the foreground colour, with the text reversed.
import { Section } from "@/components/ui/section"
const backgrounds = [
{ background: "transparent", note: "Transparent, the default: the page shows through." },
{ background: "light", note: "Light: the page background." },
{ background: "muted", note: "Muted: a quiet band between two plain ones." },
{ background: "dark", note: "Dark: the foreground colour, with the text reversed." },
] as const
export default function SectionBackgrounds() {
return (
<div className="w-full overflow-hidden rounded-md border">
{backgrounds.map(({ background, note }) => (
<Section key={background} background={background} padding="small">
<p className="px-4 text-base">{note}</p>
</Section>
))}
</div>
)
}
Padding
none
small
default
large
import { Section } from "@/components/ui/section"
const paddings = ["none", "small", "default", "large"] as const
export default function SectionPadding() {
return (
<div className="grid w-full grid-cols-2 items-start gap-2 sm:grid-cols-4">
{paddings.map((padding) => (
<Section key={padding} padding={padding} background="muted" className="rounded-md px-1">
<p className="rounded-sm bg-background py-1 text-center font-mono text-xs">{padding}</p>
</Section>
))}
</div>
)
}
Bordered
Three invoices are awaiting payment.
import { Button } from "@/components/ui/button"
import { Section } from "@/components/ui/section"
export default function SectionBordered() {
return (
<Section as="div" bordered padding="small">
<div className="flex flex-wrap items-center justify-between gap-3 px-4">
<p className="text-base">Three invoices are awaiting payment.</p>
<Button variant="outline">Review invoices</Button>
</div>
</Section>
)
}
Installation
npx shadcn@latest add @khaeli/sectionbunx --bun shadcn@latest add @khaeli/sectionInstall @khaeli/foundation first: this item's styling lives in its tokens and [data-slot] rules.
Installs with
- Registry items
- npm packages
- class-variance-authority ^0.7.1
Accessible name
- A
sectionis only a landmark when it has a name. Give itaria-labelledbypointing at its heading when the band is worth a stop in the landmark list.
Registry JSON
The item as the shadcn CLI reads it, with every file it ships: https://ui.khaeli.com/r/section.json