Heading
Render a page or section header with an optional strap, subtitle and meta content.
Heading is a client component ("use client") that renders a Text as a header containing an h1 title, plus an optional strap line above it and a subtitle paragraph below. Use it at the top of pages and sections. It reads theme overrides from theme.heading via styled-components' ThemeContext.
Website redesign
Last updated 2 hours ago
Import#
import { Heading } from "@reactberry/system/blocks";
Usage#
import { Heading, Tag } from "@reactberry/system/blocks";
import { Button } from "@reactberry/system/elements";
export default function ProjectHeader() {
return (
<Heading
strap="Projects"
title="Website redesign"
subtitle="Last updated 2 hours ago"
meta={<Tag skin="surface">In progress</Tag>}
$size="large"
>
<Button variant="primary" $size="small">
Edit project
</Button>
</Heading>
);
}
Examples#
Compact section header#
Use $size="xsmall" for headers inside cards and panels.
Members
12 people
Part overrides#
elementProps passes props to the title, subtitle and strap, for example to change the title element or colour.
Billing
Invoices and payment methods
API#
Heading#
| Prop | Type | Default | Description |
|---|---|---|---|
title | ReactNode | Page Title | Rendered in an |
subtitle | ReactNode | — | Rendered in a |
strap | any | — | Rendered in a |
meta | ReactNode | — | Rendered after the subtitle. |
elementProps | HeadingElements | {} | Per-part props keyed |
Two Text props have their own handling:
| Prop | Type | Default | Description |
|---|---|---|---|
$size | "xsmall""small""medium""large""xlarge""xxlarge""xxxlarge" | "medium" | Selects the title and subtitle font sizes. The strap uses the subtitle size. |
color | string | "primary" | Applied to the title only. |
All other TextProps are spread onto the outer header. The type also declares a props key (props?: any); it has no special handling and is forwarded with the other props.
Accessibility#
- The title is always an
h1unless overridden viaelementProps.title.as. Set it when rendering more than oneHeadingon a page. - The outer element is a
header.
Notes#
- Size mapping for title / subtitle:
xsmallmedium / small,smalllarge / small,mediumxlarge / small,largexlarge / medium,xlargexxlarge / medium,xxlargeandxxxlargexxxlarge / xlarge. - Passing a
$sizeoutside the listed keys throws at render time, because the size lookup returnsundefined. - Style precedence for each part is component defaults, then
theme.heading.title/subtitle/strap, thenelementProps. The default themes set the subtitle and strap colours, so the component's own"tertiary"subtitle and"secondary"strap colours are overridden by the theme. - The outer
headerreceivestheme.heading.container(a flex column with vertical padding in the default themes) before your props.