Heading
Page headline component: a responsive h1 for landing page heroes and page titles. One size that scales from mobile to desktop, balances its line breaks, and uses your display font. Pair with Text for the lead paragraph.
pnpm dlx shadcn add @01orbital/headingimport { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cn } from "cn"
// No width of its own: whatever holds it (a HeroContent, a SectionHeader)
// is the measure. text-balance shares a wrapped headline's lines evenly.
// font-display follows font-sans unless the block switches it, for example
// with [--font-display:var(--font-serif)].
/**
* The page headline in the display font, rendered as an `<h1>`: 48px with a
* 48px line, 64px with a 64px line from the `sm` breakpoint. One size, no
* props beyond the element's own; pass `render` to use another element. Its
* lines are balanced when it wraps. Section and card titles use `Subheading`.
*/
function Heading({
className,
render,
...props
}: useRender.ComponentProps<"h1">) {
return useRender({
defaultTagName: "h1",
render,
state: { slot: "heading" },
props: mergeProps<"h1">(
{
className: cn(
"font-display text-5xl/12 tracking-[-0.04em] text-balance wrap-anywhere sm:text-[4rem]/16",
className
),
},
props
),
})
}
export { Heading }
import { Heading } from "@/components/heading/heading"
import {
Section,
SectionContent,
} from "@/components/section/section"
const COPY = {
text: "Plan the release, not the meeting about it",
}
export default function HeadingDemo() {
return (
<Section className="py-0">
<SectionContent className="px-0 lg:px-0">
<Heading>{COPY.text}</Heading>
</SectionContent>
</Section>
)
}
import type { ComponentProps } from "react"
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "cn"
const sectionVariants = cva(
"relative isolate w-full bg-background wrap-anywhere text-foreground",
{
variants: {
size: { sm: "py-16", md: "py-24", lg: "py-32" },
},
defaultVariants: { size: "md" },
}
)
const columnVariants = cva(
"mx-auto flex w-full max-w-7xl min-w-0 flex-col px-6 lg:px-10",
{
variants: {
size: {
sm: "gap-10",
md: "gap-10 sm:gap-16",
lg: "gap-16",
},
},
defaultVariants: { size: "md" },
}
)
function Section({
className,
size = "md",
children,
...props
}: ComponentProps<"section"> & VariantProps<typeof sectionVariants>) {
return (
<section
data-slot="section"
data-size={size}
className={cn(sectionVariants({ size }), className)}
{...props}
>
<div data-slot="section-column" className={columnVariants({ size })}>
{children}
</div>
</section>
)
}
function SectionBackground({ className, ...props }: ComponentProps<"div">) {
return (
<div
data-slot="section-background"
aria-hidden="true"
className={cn("pointer-events-none absolute inset-0 -z-10", className)}
{...props}
/>
)
}
const contentVariants = cva("mx-auto flex w-full min-w-0 flex-col", {
variants: {
/**
* The gap between children: `sm` 24px, `md` (the default) 32px, `lg`
* 64px.
*/
size: {
sm: "gap-6",
md: "gap-8",
lg: "gap-16",
},
width: {
sm: "max-w-2xl",
md: "max-w-2xl md:max-w-3xl",
lg: "max-w-2xl md:max-w-3xl lg:max-w-4xl",
xl: "max-w-2xl md:max-w-3xl lg:max-w-5xl",
full: "max-w-7xl",
},
},
defaultVariants: { size: "md", width: "full" },
})
function SectionContent({
className,
size = "md",
width = "full",
render,
...props
}: useRender.ComponentProps<"div"> & VariantProps<typeof contentVariants>) {
return useRender({
defaultTagName: "div",
render,
state: { slot: "section-content", width },
props: mergeProps<"div">(
{
className: cn(contentVariants({ size, width }), className),
},
props
),
})
}
const columnsVariants = cva(
"grid w-full max-w-2xl grid-cols-1 items-start gap-x-(--gutter) gap-y-(--row-gap) lg:max-w-none",
{
variants: {
variant: {
equal: "lg:grid-cols-2",
intro: "lg:grid-cols-[2fr_3fr]",
},
},
defaultVariants: { variant: "equal" },
}
)
function SectionColumns({
className,
variant = "equal",
...props
}: ComponentProps<"div"> & VariantProps<typeof columnsVariants>) {
return (
<div
data-slot="section-columns"
data-variant={variant}
className={cn(columnsVariants({ variant }), className)}
{...props}
/>
)
}
const headerVariants = cva("group/section-header grid w-full min-w-0 gap-6", {
variants: {
size: {
md: "max-w-2xl",
lg: "max-w-4xl",
},
align: {
start: "justify-items-start",
center: "mx-auto justify-items-center text-center",
},
variant: {
stack: "",
split:
"max-w-none sm:grid-cols-[1fr_auto] sm:items-end sm:*:data-[slot=section-actions]:col-start-2 sm:*:data-[slot=section-actions]:row-start-1",
},
},
defaultVariants: { align: "start", size: "md", variant: "stack" },
})
type SectionHeaderProps = ComponentProps<"div"> &
(
| (Omit<VariantProps<typeof headerVariants>, "variant"> & {
variant?: "stack"
})
| {
variant: "split"
size?: never
align?: never
}
)
function SectionHeader({
className,
align = "start",
size = "md",
variant = "stack",
...props
}: SectionHeaderProps) {
return (
<div
data-slot="section-header"
data-align={align}
data-size={size}
data-variant={variant}
className={cn(headerVariants({ align, size, variant }), className)}
{...props}
/>
)
}
const sectionActionsVariants = cva(
"flex max-w-full flex-wrap items-center gap-4",
{
variants: {
align: {
start: "",
center: "justify-center",
},
},
defaultVariants: { align: "start" },
}
)
function SectionActions({
className,
align = "start",
...props
}: ComponentProps<"div"> & VariantProps<typeof sectionActionsVariants>) {
return (
<div
data-slot="section-actions"
data-align={align}
className={cn(sectionActionsVariants({ align }), className)}
{...props}
/>
)
}
const titleGroupVariants = cva("grid w-full min-w-0", {
variants: {
direction: {
column: "",
row: "lg:grid-cols-2 lg:items-end lg:gap-x-(--gutter)",
},
gap: {
sm: "gap-2",
md: "gap-3",
lg: "gap-6",
},
},
defaultVariants: { direction: "column", gap: "sm" },
})
function SectionTitleGroup({
className,
direction = "column",
gap = "sm",
...props
}: ComponentProps<"div"> & VariantProps<typeof titleGroupVariants>) {
return (
<div
data-slot="section-title-group"
data-direction={direction}
data-gap={gap}
className={cn(titleGroupVariants({ direction, gap }), className)}
{...props}
/>
)
}
export {
Section,
SectionBackground,
SectionContent,
SectionColumns,
SectionHeader,
SectionTitleGroup,
SectionActions,
}
The example also uses section. Install it too:
pnpm dlx shadcn add @01orbital/sectionnpx shadcn add @01orbital/sectionyarn shadcn add @01orbital/sectionbunx --bun shadcn add @01orbital/sectionUsage
import { Heading } from "@/components/heading/heading"
import {
Section,
SectionContent,
} from "@/components/section/section"
const COPY = {
text: "Plan the release, not the meeting about it",
}
export default function HeadingDemo() {
return (
<Section className="py-0">
<SectionContent className="px-0 lg:px-0">
<Heading>{COPY.text}</Heading>
</SectionContent>
</Section>
)
}Examples
Catalogue Raisonneheading-catalogue-raisonne
Heading Catalogue Raisonne: an example of heading.
pnpm dlx shadcn add @01orbital/heading-catalogue-raisonneimport { Eyebrow } from "@/components/eyebrow/eyebrow"
import { Heading } from "@/components/heading/heading"
import { Text } from "@/components/text/text"
// The copy: change text here, not in the markup.
const COPY = {
label: "Catalogue raisonné",
title: "Ellis Marchetti, 1962 to 1998",
body: "Every known painting, drawing and sketchbook, with provenance and exhibition history.",
} as const
const FACTS = [
{ label: "Works", value: "312" },
{ label: "Volumes", value: "2" },
{ label: "Edition", value: "Second" },
] as const
/** A scholarly catalogue title page with a row of facts under a rule. */
export default function HeadingCatalogueRaisonne() {
return (
<section className="flex w-full max-w-3xl flex-col gap-8 px-6 py-16">
<Eyebrow variant="caps">{COPY.label}</Eyebrow>
<Heading className="[--font-display:var(--font-serif)]">
{COPY.title}
</Heading>
<Text variant="muted" className="max-w-lg">
{COPY.body}
</Text>
<dl className="flex gap-10 border-t pt-5 text-sm">
{FACTS.map((fact) => (
<div key={fact.label} className="flex flex-col gap-1">
<dt className="text-muted-foreground">{fact.label}</dt>
<dd className="font-medium">{fact.value}</dd>
</div>
))}
</dl>
</section>
)
}
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "cn"
// default is a quiet 14px line, cased as written; icon puts a 16px icon in
// front of it; mono is a 12px uppercase mono label for spec-sheet designs;
// caps is the same size in a sans face. tone picks the ink: muted (the
// default) or the surrounding text color, for a label over art or on a dark
// island where muted-foreground is too quiet.
const eyebrowVariants = cva("", {
variants: {
/**
* The label style. `default` (the default) is a 14px line at weight 500,
* cased as written. `icon` is the same line with a 16px icon, placed
* first among the children, 12px before the words. `mono` is a 12px
* uppercase mono label at weight 500 with 0.12em letter spacing. `caps`
* is the same label in the sans face, for a brand and series label such
* as "Studio Neri / Clay school". The color comes from `tone`.
*/
variant: {
default: "text-sm/5 font-medium",
icon: "flex items-center gap-3 text-sm/5 font-medium [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
mono: "font-mono text-xs/5 font-medium tracking-[0.12em] uppercase",
caps: "text-xs/5 font-medium tracking-[0.12em] uppercase",
},
/**
* The ink. `muted` (the default) is `muted-foreground`. `ink` leaves the
* color to the surrounding text, for a label over art, on a dark island
* or anywhere the muted grey is too quiet to read.
*/
tone: {
muted: "text-muted-foreground",
ink: "",
},
},
defaultVariants: { variant: "default", tone: "muted" },
})
/**
* A short label set above a heading, such as a section name, rendered as a
* `<p>`. Leave 8px between it and the heading. Pass `render` to use another
* element.
*
* `default` is a 14px line at weight 500, cased as written. `icon` adds a
* 16px icon before the words: put the icon first, with `aria-hidden`. `mono`
* is a 12px uppercase mono label with 0.12em letter spacing; `caps` the same
* in the sans face, for a brand and series name such as "Studio Neri / Clay
* school". `tone="muted"` (the default) sets it in `muted-foreground`;
* `tone="ink"` takes the surrounding text color, for a label over art or on
* a dark island where the grey is too quiet.
*/
function Eyebrow({
className,
variant = "default",
tone = "muted",
render,
...props
}: useRender.ComponentProps<"p"> & VariantProps<typeof eyebrowVariants>) {
return useRender({
defaultTagName: "p",
render,
state: { slot: "eyebrow", variant, tone },
props: mergeProps<"p">(
{ className: cn(eyebrowVariants({ variant, tone }), className) },
props
),
})
}
export { Eyebrow, eyebrowVariants }
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cn } from "cn"
// No width of its own: whatever holds it (a HeroContent, a SectionHeader)
// is the measure. text-balance shares a wrapped headline's lines evenly.
// font-display follows font-sans unless the block switches it, for example
// with [--font-display:var(--font-serif)].
/**
* The page headline in the display font, rendered as an `<h1>`: 48px with a
* 48px line, 64px with a 64px line from the `sm` breakpoint. One size, no
* props beyond the element's own; pass `render` to use another element. Its
* lines are balanced when it wraps. Section and card titles use `Subheading`.
*/
function Heading({
className,
render,
...props
}: useRender.ComponentProps<"h1">) {
return useRender({
defaultTagName: "h1",
render,
state: { slot: "heading" },
props: mergeProps<"h1">(
{
className: cn(
"font-display text-5xl/12 tracking-[-0.04em] text-balance wrap-anywhere sm:text-[4rem]/16",
className
),
},
props
),
})
}
export { Heading }
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "cn"
// The paragraph under a Heading or Subheading, in a hero or a section
// header. No width of its own: give it one with a `max-w-*` class when the
// layout wants it. Inherits the surrounding ink, so it reads over art;
// muted steps it down on a flat ground.
const textVariants = cva("w-full min-w-0 text-pretty", {
variants: {
/**
* The text color. `default` (the default) keeps the inherited color.
* `muted` uses `muted-foreground`.
*/
variant: {
default: "",
muted: "text-muted-foreground",
},
/**
* The text size: `md` (the default) 16px with 28px lines, `lg` 18px
* with 32px lines, the lead under a page headline.
*/
size: {
md: "text-base/7",
lg: "text-lg/8",
},
},
defaultVariants: { variant: "default", size: "md" },
})
/**
* The paragraph under a heading, a `p` by default. For several paragraphs,
* pass `render={<div />}` and put your own `p` elements inside.
*
* `size` sets the text: `md` (the default) 16px with 28px lines, `lg` 18px
* with 32px lines for the lead under a page headline. `variant="muted"`
* uses the muted text color; the default inherits the ink around it.
*/
function Text({
className,
variant = "default",
size = "md",
render,
...props
}: useRender.ComponentProps<"p"> & VariantProps<typeof textVariants>) {
return useRender({
defaultTagName: "p",
render,
state: { slot: "text", variant, size },
props: mergeProps<"p">(
{ className: cn(textVariants({ variant, size }), className) },
props
),
})
}
export { Text }
Cover Headline With Bylineheading-cover-headline-byline
Cover Headline With Byline: an example of heading.
pnpm dlx shadcn add @01orbital/heading-cover-headline-bylineimport { Eyebrow } from "@/components/eyebrow/eyebrow"
import { Heading } from "@/components/heading/heading"
import { Text } from "@/components/text/text"
// The copy: change text here, not in the markup.
const COPY = {
issue: "Issue 14 · Autumn",
title: "The slow return of handmade type",
deck: "Seven studios, one long afternoon, and the quiet case for setting letters by hand.",
byline: "Words by Mara Olsen · Photographs by Ines Duarte",
} as const
/** A magazine cover block with an oversized serif headline under an issue line. */
export default function HeadingCoverHeadlineByline() {
return (
<section className="flex w-full max-w-3xl flex-col gap-6 px-6 py-16">
<Eyebrow variant="caps">{COPY.issue}</Eyebrow>
<Heading className="[--font-display:var(--font-serif)] sm:text-7xl/[4.5rem]">
{COPY.title}
</Heading>
<Text size="lg" variant="muted" className="max-w-xl">
{COPY.deck}
</Text>
<p className="text-sm text-muted-foreground">{COPY.byline}</p>
</section>
)
}
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "cn"
// default is a quiet 14px line, cased as written; icon puts a 16px icon in
// front of it; mono is a 12px uppercase mono label for spec-sheet designs;
// caps is the same size in a sans face. tone picks the ink: muted (the
// default) or the surrounding text color, for a label over art or on a dark
// island where muted-foreground is too quiet.
const eyebrowVariants = cva("", {
variants: {
/**
* The label style. `default` (the default) is a 14px line at weight 500,
* cased as written. `icon` is the same line with a 16px icon, placed
* first among the children, 12px before the words. `mono` is a 12px
* uppercase mono label at weight 500 with 0.12em letter spacing. `caps`
* is the same label in the sans face, for a brand and series label such
* as "Studio Neri / Clay school". The color comes from `tone`.
*/
variant: {
default: "text-sm/5 font-medium",
icon: "flex items-center gap-3 text-sm/5 font-medium [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
mono: "font-mono text-xs/5 font-medium tracking-[0.12em] uppercase",
caps: "text-xs/5 font-medium tracking-[0.12em] uppercase",
},
/**
* The ink. `muted` (the default) is `muted-foreground`. `ink` leaves the
* color to the surrounding text, for a label over art, on a dark island
* or anywhere the muted grey is too quiet to read.
*/
tone: {
muted: "text-muted-foreground",
ink: "",
},
},
defaultVariants: { variant: "default", tone: "muted" },
})
/**
* A short label set above a heading, such as a section name, rendered as a
* `<p>`. Leave 8px between it and the heading. Pass `render` to use another
* element.
*
* `default` is a 14px line at weight 500, cased as written. `icon` adds a
* 16px icon before the words: put the icon first, with `aria-hidden`. `mono`
* is a 12px uppercase mono label with 0.12em letter spacing; `caps` the same
* in the sans face, for a brand and series name such as "Studio Neri / Clay
* school". `tone="muted"` (the default) sets it in `muted-foreground`;
* `tone="ink"` takes the surrounding text color, for a label over art or on
* a dark island where the grey is too quiet.
*/
function Eyebrow({
className,
variant = "default",
tone = "muted",
render,
...props
}: useRender.ComponentProps<"p"> & VariantProps<typeof eyebrowVariants>) {
return useRender({
defaultTagName: "p",
render,
state: { slot: "eyebrow", variant, tone },
props: mergeProps<"p">(
{ className: cn(eyebrowVariants({ variant, tone }), className) },
props
),
})
}
export { Eyebrow, eyebrowVariants }
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cn } from "cn"
// No width of its own: whatever holds it (a HeroContent, a SectionHeader)
// is the measure. text-balance shares a wrapped headline's lines evenly.
// font-display follows font-sans unless the block switches it, for example
// with [--font-display:var(--font-serif)].
/**
* The page headline in the display font, rendered as an `<h1>`: 48px with a
* 48px line, 64px with a 64px line from the `sm` breakpoint. One size, no
* props beyond the element's own; pass `render` to use another element. Its
* lines are balanced when it wraps. Section and card titles use `Subheading`.
*/
function Heading({
className,
render,
...props
}: useRender.ComponentProps<"h1">) {
return useRender({
defaultTagName: "h1",
render,
state: { slot: "heading" },
props: mergeProps<"h1">(
{
className: cn(
"font-display text-5xl/12 tracking-[-0.04em] text-balance wrap-anywhere sm:text-[4rem]/16",
className
),
},
props
),
})
}
export { Heading }
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "cn"
// The paragraph under a Heading or Subheading, in a hero or a section
// header. No width of its own: give it one with a `max-w-*` class when the
// layout wants it. Inherits the surrounding ink, so it reads over art;
// muted steps it down on a flat ground.
const textVariants = cva("w-full min-w-0 text-pretty", {
variants: {
/**
* The text color. `default` (the default) keeps the inherited color.
* `muted` uses `muted-foreground`.
*/
variant: {
default: "",
muted: "text-muted-foreground",
},
/**
* The text size: `md` (the default) 16px with 28px lines, `lg` 18px
* with 32px lines, the lead under a page headline.
*/
size: {
md: "text-base/7",
lg: "text-lg/8",
},
},
defaultVariants: { variant: "default", size: "md" },
})
/**
* The paragraph under a heading, a `p` by default. For several paragraphs,
* pass `render={<div />}` and put your own `p` elements inside.
*
* `size` sets the text: `md` (the default) 16px with 28px lines, `lg` 18px
* with 32px lines for the lead under a page headline. `variant="muted"`
* uses the muted text color; the default inherits the ink around it.
*/
function Text({
className,
variant = "default",
size = "md",
render,
...props
}: useRender.ComponentProps<"p"> & VariantProps<typeof textVariants>) {
return useRender({
defaultTagName: "p",
render,
state: { slot: "text", variant, size },
props: mergeProps<"p">(
{ className: cn(textVariants({ variant, size }), className) },
props
),
})
}
export { Text }
Landing Heroheading-landing-hero
Heading Landing Hero: an example of heading.
pnpm dlx shadcn add @01orbital/heading-landing-heroimport { cn } from "cn"
import { Heading } from "@/components/heading/heading"
import { Text } from "@/components/text/text"
import { buttonVariants } from "@/components/ui/button"
// The copy: change text here, not in the markup.
const COPY = {
title: "Plan your week in one calm place",
body: "Fieldnote turns scattered tasks, notes and meetings into a single plan you can trust.",
primary: "Start free",
secondary: "See how it works",
} as const
/** A centered landing-page hero: headline, one sentence, two actions. */
export default function HeadingLandingHero() {
return (
<section className="flex w-full max-w-3xl flex-col items-center gap-6 px-6 py-20 text-center">
<Heading>{COPY.title}</Heading>
<Text size="lg" variant="muted" className="max-w-xl">
{COPY.body}
</Text>
<div className="flex flex-wrap justify-center gap-3">
<a href="#start" className={cn(buttonVariants({ size: "lg" }))}>
{COPY.primary}
</a>
<a
href="#tour"
className={cn(buttonVariants({ variant: "outline", size: "lg" }))}
>
{COPY.secondary}
</a>
</div>
</section>
)
}
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cn } from "cn"
// No width of its own: whatever holds it (a HeroContent, a SectionHeader)
// is the measure. text-balance shares a wrapped headline's lines evenly.
// font-display follows font-sans unless the block switches it, for example
// with [--font-display:var(--font-serif)].
/**
* The page headline in the display font, rendered as an `<h1>`: 48px with a
* 48px line, 64px with a 64px line from the `sm` breakpoint. One size, no
* props beyond the element's own; pass `render` to use another element. Its
* lines are balanced when it wraps. Section and card titles use `Subheading`.
*/
function Heading({
className,
render,
...props
}: useRender.ComponentProps<"h1">) {
return useRender({
defaultTagName: "h1",
render,
state: { slot: "heading" },
props: mergeProps<"h1">(
{
className: cn(
"font-display text-5xl/12 tracking-[-0.04em] text-balance wrap-anywhere sm:text-[4rem]/16",
className
),
},
props
),
})
}
export { Heading }
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "cn"
// The paragraph under a Heading or Subheading, in a hero or a section
// header. No width of its own: give it one with a `max-w-*` class when the
// layout wants it. Inherits the surrounding ink, so it reads over art;
// muted steps it down on a flat ground.
const textVariants = cva("w-full min-w-0 text-pretty", {
variants: {
/**
* The text color. `default` (the default) keeps the inherited color.
* `muted` uses `muted-foreground`.
*/
variant: {
default: "",
muted: "text-muted-foreground",
},
/**
* The text size: `md` (the default) 16px with 28px lines, `lg` 18px
* with 32px lines, the lead under a page headline.
*/
size: {
md: "text-base/7",
lg: "text-lg/8",
},
},
defaultVariants: { variant: "default", size: "md" },
})
/**
* The paragraph under a heading, a `p` by default. For several paragraphs,
* pass `render={<div />}` and put your own `p` elements inside.
*
* `size` sets the text: `md` (the default) 16px with 28px lines, `lg` 18px
* with 32px lines for the lead under a page headline. `variant="muted"`
* uses the muted text color; the default inherits the ink around it.
*/
function Text({
className,
variant = "default",
size = "md",
render,
...props
}: useRender.ComponentProps<"p"> & VariantProps<typeof textVariants>) {
return useRender({
defaultTagName: "p",
render,
state: { slot: "text", variant, size },
props: mergeProps<"p">(
{ className: cn(textVariants({ variant, size }), className) },
props
),
})
}
export { Text }
Serif Signed Statement Headingheading-serif-signed-statement
Serif Signed Statement Heading: an example of heading.
pnpm dlx shadcn add @01orbital/heading-serif-signed-statementimport { Heading } from "@/components/heading/heading"
// The copy: change text here, not in the markup.
const COPY = {
label: "Artist statement",
title: "I paint the hour before rain.",
paragraphs: [
"My canvases begin with a single colour mixed from whatever the sky is doing, then slowly argue with it.",
"The work asks viewers to stand still for a minute longer than is comfortable.",
],
name: "Noor Haddad",
} as const
/** An artist statement with a headline, two paragraphs and a signature. */
export default function HeadingSerifSignedStatement() {
return (
<section className="flex w-full max-w-2xl flex-col gap-6 px-6 py-16">
<p className="text-sm text-muted-foreground">{COPY.label}</p>
<Heading className="[--font-display:var(--font-serif)]">
{COPY.title}
</Heading>
<div className="flex flex-col gap-4 text-base/7 text-muted-foreground">
{COPY.paragraphs.map((text) => (
<p key={text}>{text}</p>
))}
</div>
<p className="font-medium">{COPY.name}</p>
</section>
)
}
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cn } from "cn"
// No width of its own: whatever holds it (a HeroContent, a SectionHeader)
// is the measure. text-balance shares a wrapped headline's lines evenly.
// font-display follows font-sans unless the block switches it, for example
// with [--font-display:var(--font-serif)].
/**
* The page headline in the display font, rendered as an `<h1>`: 48px with a
* 48px line, 64px with a 64px line from the `sm` breakpoint. One size, no
* props beyond the element's own; pass `render` to use another element. Its
* lines are balanced when it wraps. Section and card titles use `Subheading`.
*/
function Heading({
className,
render,
...props
}: useRender.ComponentProps<"h1">) {
return useRender({
defaultTagName: "h1",
render,
state: { slot: "heading" },
props: mergeProps<"h1">(
{
className: cn(
"font-display text-5xl/12 tracking-[-0.04em] text-balance wrap-anywhere sm:text-[4rem]/16",
className
),
},
props
),
})
}
export { Heading }
API reference
The page headline in the display font, rendered as an <h1>: 48px with a 48px line, 64px with a 64px line from the sm breakpoint. One size, no props beyond the element's own; pass render to use another element. Its lines are balanced when it wraps. Section and card titles use Subheading.
It accepts the props of the Base UI part it wraps, and the HTML attributes of the element it renders.
Dependencies
npm: @base-ui/react, cn. The CLI installs them for you. cn merges Tailwind class names, in place of clsx and tailwind-merge.
Used in blocks
27 blocks are built with Heading; the first 12: