Section heading
Heading group for a page section: an optional uppercase eyebrow, a large title and a muted description, left or centered.
pnpm dlx shadcn@latest add @haze/section-heading---
import { cn } from "../../../lib/haze/utils";
interface Props {
title: string;
/** Short label above the title. */
eyebrow?: string;
description?: string;
align?: "left" | "center";
/** Heading level of the title. Use 1 only once per page. */
headingLevel?: 1 | 2 | 3;
/** Put on the heading so a <section aria-labelledby> can point at it. */
id?: string;
class?: string;
}
const { title, eyebrow, description, align = "left", headingLevel = 2, id, class: className } = Astro.props;
const Heading = ({ 1: "h1", 2: "h2", 3: "h3" } as const)[headingLevel];
const aligns = { left: "text-left", center: "mx-auto text-center" };
const descriptionAligns = { left: "", center: "mx-auto" };
---
<div class={cn("grid max-w-2xl gap-3", aligns[align], className)}>
{eyebrow && <p class="text-xs/4 font-medium text-muted-foreground">{eyebrow}</p>}
<Heading id={id} class="text-3xl/9 font-medium tracking-tight text-balance text-foreground sm:text-4xl/11">{title}</Heading>
{description && <p class={cn("max-w-2xl text-base/7 text-pretty text-muted-foreground", descriptionAligns[align])}>{description}</p>}
</div>When to use
- Opening a landing-page section such as features, pricing or FAQ
- A title with a one-line intro that needs the same type scale on every section
- Pointing a <section aria-labelledby> at its heading through the id prop
When not to use
- A heading inside a card or a dialog; those components take their own title prop
- Body-size subheadings in running text; use a plain heading with prose classes
Installation
Add the Haze registry to components.json once, then install Section heading with the shadcn CLI. Works in any Astro project with Tailwind CSS v4.
pnpm dlx shadcn@latest add @haze/section-headingnpx shadcn@latest add @haze/section-headingyarn dlx shadcn@latest add @haze/section-headingbunx --bun shadcn@latest add @haze/section-headingFirst time? Registry and theme setup
1. Add to components.json:
{
"registries": {
"@haze": "http://localhost:4329/r/{name}.json"
}
}2. Install the theme once: npx shadcn@latest add @haze/theme, then import it after Tailwind in your global CSS:@import "./haze.css";
API reference
| Prop | Type | Default | Description |
|---|---|---|---|
| title* | string | – | The heading text. |
| eyebrow | string | – | Short label above the title, drawn as a muted uppercase micro-label. |
| description | string | – | Muted paragraph under the title, at most 42 rem wide. |
| align | "left" | "center" | "left" | Text alignment; center also centers the box and the description in the parent. |
| headingLevel | 1 | 2 | 3 | 2 | Tag of the title. Visual size stays the same at every level. |
| id | string | – | Set on the heading element, for aria-labelledby on the surrounding section. |
| class | string | – | Extra classes on the wrapper. |
Accessibility
- The title level is a prop, so the size you see is decoupled from the outline; a section under an h2 page title should use 3.
- The eyebrow is a paragraph outside the heading, so screen reader heading lists show only the title.
- Use headingLevel 1 once per page; the default 2 assumes the page already has its h1.
Notes for AI
Copy into Claude Code, Cursor, Codex or any coding agent. Agents can also read the Markdown version of this page.
Install and use
Install the Haze UI component "Section heading" with `npx shadcn@latest add @haze/section-heading`. If components.json has no "@haze" registry yet, add "registries": { "@haze": "http://localhost:4329/r/{name}.json" }. If src/styles/haze.css does not exist yet, run `npx shadcn@latest add @haze/theme` once and import it from the global stylesheet after Tailwind. The CLI stops at an overwrite question when a Haze file already exists and differs, even with --yes, and then installs nothing after it: read its output. If the user has not edited their Haze files, re-run with --overwrite to take the registry versions; if they have, ask them before overwriting. Then import SectionHeading from "@/components/haze/ui/section-heading.astro" (or the relative path) and render it where it fits the page. Keep Haze token classes (bg-background, text-muted-foreground, border-border...) and never hardcode colors. Docs: http://localhost:4329/ui/section-heading.md
Customize with real content
Adapt the Haze section-heading ui for our product. Replace the demo values of these props with our real content: title, eyebrow, description, align, headingLevel, id, class. Keep the layout, the heading level rules and these accessibility details: The title level is a prop, so the size you see is decoupled from the outline; a section under an h2 page title should use 3. The eyebrow is a paragraph outside the heading, so screen reader heading lists show only the title. Use headingLevel 1 once per page; the default 2 assumes the page already has its h1. Do not add raw color classes; use the Haze tokens.
Choose the right block
Before using section-heading, check it fits: use it when opening a landing-page section such as features, pricing or faq; a title with a one-line intro that needs the same type scale on every section; pointing a <section aria-labelledby> at its heading through the id prop. Avoid it when a heading inside a card or a dialog; those components take their own title prop; body-size subheadings in running text; use a plain heading with prose classes. Alternatives: @haze/card, @haze/separator.
Dependencies
- @haze/utils
- @haze/theme (one-time setup)
Source · Original Haze UI work.