A page's title, description, breadcrumb and actions.
Invoice sync
LiveOwner Maya ChenRuns hourly1,284 runs this month
Copies new invoices from the ledger into the finance workspace and flags any over 10,000.
import type { Html } from "@effect/ui/html"import * as stylex from "@stylexjs/stylex"import { Badge } from "./ui/uicontext/components/Badge.ts"import { Button } from "./ui/uicontext/components/Button.ts"import { PageHeader } from "./ui/uicontext/components/PageHeader.ts"import { sx } from "./ui/uicontext/components/Sx.ts"import { color, font, space } from "./ui/uicontext/components/tokens.stylex.ts"const styles = stylex.create({ frame: { inlineSize: "min(100%, 44rem)" }, crumbs: { display: "flex", gap: space.xs, fontSize: font.sm, color: color.muted }, link: { color: "inherit" }, facts: { margin: 0, display: "flex", flexWrap: "wrap", columnGap: space.lg, rowGap: space.xxs, fontSize: font.sm, color: color.muted },})export const WorkflowHeader = <M>(h: Html.H<M>) => h.div.attrs(sx(styles.frame)).children( PageHeader(h, { title: "Invoice sync", breadcrumb: h.div.attrs(sx(styles.crumbs)).children(h.a.attrs({ href: "#workflows", ...sx(styles.link) }).children("Workflows"), "/", "Finance"), accessory: Badge(h, { tone: "success", dot: true, emphasis: "outline" }).children("Live"), metadata: h.p.attrs(sx(styles.facts)).children(h.span.children("Owner Maya Chen"), h.span.children("Runs hourly"), h.span.children("1,284 runs this month")), description: "Copies new invoices from the ledger into the finance workspace and flags any over 10,000.", actions: [Button(h).children("Run now"), Button(h, { tone: "primary" }).children("Edit workflow")], }), )Installation
pnpm dlx shadcn@latest add checkfu/uicontext/page-headerUsage
import { Button } from "./ui/uicontext/components/Button.ts"import { PageHeader } from "./ui/uicontext/components/PageHeader.ts"export const ProjectsHeader = <M>(h: Html.H<M>, newProject: M) => PageHeader(h, { title: "Projects", description: "Plan and share work across your team.", actions: Button(h, { tone: "primary" }).on("click", newProject).children("New project"), })Examples
A long title in a narrow column
The title wraps in balanced lines; the actions move under it.
Sign-in link expires before the email arrives for people on corporate mail servers
import type { Html } from "@effect/ui/html"import * as stylex from "@stylexjs/stylex"import { Button } from "./ui/uicontext/components/Button.ts"import { PageHeader } from "./ui/uicontext/components/PageHeader.ts"import { sx } from "./ui/uicontext/components/Sx.ts"const styles = stylex.create({ frame: { inlineSize: "min(100%, 26rem)" } })// a long title wraps in balanced lines, and the actions move under it when there's no room beside itexport const LongTitle = <M>(h: Html.H<M>) => h.div.attrs(sx(styles.frame)).children( PageHeader(h, { title: "Sign-in link expires before the email arrives for people on corporate mail servers", headingLevel: 2, actions: [Button(h, { size: "sm" }).children("Subscribe"), Button(h, { size: "sm", tone: "primary" }).children("Assign to me")], }), )API reference
Options
| Name | Type | Default | Description |
|---|---|---|---|
titlerequired | string | — | The page's name, as its heading. |
headingLevel | 1 | 2 | 3 | 1 | The title's heading level: 1 for a page, 2 or 3 for a section inside one; 1 by default. |
titleId | string | — | The heading's id, so a region can name itself by it. |
titleStyle | Style | — | StyleX styles for the heading, applied after its own. |
focus | boolean | — | Moves focus to the heading once it appears, as after a route change, so screen readers start there. |
description | string | — | A sentence under the title on what the page is for. |
actions | View.Input | — | Buttons at the end of the title row, such as New or Share. |
breadcrumb | View.Input | — | Where the page sits, above the title, in a Breadcrumb landmark. |
accessory | View.Input | — | Something right after the title, such as a status badge or a favorite button. |
metadata | View.Input | — | A line of facts under the title: an owner, a date, a count. |
Accessibility
- The title is a heading (
h1unless you setheadingLevel); withfocus, it takes focus after navigation so screen readers start there. - The breadcrumb is a
navlandmark named Breadcrumb.