Heading
A section heading. Size and semantics are separate props, so a visually small
heading can still be an h2 where the document structure calls for one.
import { Heading } from "antlitz";
API
| Prop | Type | Default |
|---|---|---|
| as | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | h2 |
| asChild | boolean | false |
| size | "xs" | "sm" | "md" | "lg" | "xl" | md |
| tone | "base" | "muted" | "subtle" | base |
| weight | "medium" | "semibold" | "bold" | "black" | semibold |
as accepts h1 through h6 only — a heading component that could render a
div would defeat the point.
Sizes
Extra large
Large
Medium
Small
Extra small
export function Sizes() {
return (
<>
<Heading size="xl">Extra large</Heading>
<Heading size="lg">Large</Heading>
<Heading size="md">Medium</Heading>
<Heading size="sm">Small</Heading>
<Heading size="xs">Extra small</Heading>
</>
);
}Every size steps up one level from the lg breakpoint, so headings stay in
proportion on small screens without a second set of props.
Weights
Medium
Semibold
Bold
Black
export function Weights() {
return (
<>
<Heading as="h3" weight="medium">
Medium
</Heading>
<Heading as="h3" weight="semibold">
Semibold
</Heading>
<Heading as="h3" weight="bold">
Bold
</Heading>
<Heading as="h3" weight="black">
Black
</Heading>
</>
);
}Tones
Base
Muted
Subtle
export function Tones() {
return (
<>
<Heading as="h3" tone="base">
Base
</Heading>
<Heading as="h3" tone="muted">
Muted
</Heading>
<Heading as="h3" tone="subtle">
Subtle
</Heading>
</>
);
}Semantics
Rendered as h3
Wrapping an existing h4
export function Semantics() {
return (
<>
<Heading as="h3" size="sm">
Rendered as h3
</Heading>
<Heading asChild size="sm" tone="muted">
<h4>Wrapping an existing h4</h4>
</Heading>
</>
);
}Choose as from the document outline and size from the design. Skipping
heading levels to get a smaller size is the mistake this split prevents.
Headings are text-balance, so short headings break into even lines rather
than leaving one word alone.