Header

The bar on top of a dialog, a sheet or a panel: an action on each side and a title.

Usage

tsx
<Header>
  <Header.Leading>
    <Button aria-label="back" onClick={goBack}>
      <Button.Icon><MdArrowBack /></Button.Icon>
    </Button>
  </Header.Leading>
  <Header.Title>Release notes</Header.Title>
  <Header.Trailing>
    <Button aria-label="close" onClick={close}>
      <Button.Icon><MdClose /></Button.Icon>
    </Button>
  </Header.Trailing>
</Header>
Release notes

Only some parts

Every part is optional. The trailing part stays on the right even without a title.

tsx
<Header>
  <Header.Title>Invoices</Header.Title>
</Header>

<Header>
  <Header.Leading>
    <Button aria-label="back" onClick={goBack}>
      <Button.Icon><MdArrowBack /></Button.Icon>
    </Button>
  </Header.Leading>
  <Header.Trailing>
    <Button aria-label="close" onClick={close}>
      <Button.Icon><MdClose /></Button.Icon>
    </Button>
  </Header.Trailing>
</Header>
Invoices

Anything in between

Elements that aren't parts sit in the row after the title.

tsx
<Header>
  <Header.Title>Invoice 0142</Header.Title>
  <Chip active>overdue</Chip>
  <Header.Trailing>
    <Button aria-label="share" onClick={share}>
      <Button.Icon><MdShare /></Button.Icon>
    </Button>
    <Button aria-label="delete" onClick={remove}>
      <Button.Icon><MdDelete /></Button.Icon>
    </Button>
  </Header.Trailing>
</Header>
Invoice 0142
overdue

Long titles

The title stops at two lines. Add items-start to keep the actions at the top.

tsx
<Header>
  <Header.Leading>{back}</Header.Leading>
  <Header.Title>{longTitle}</Header.Title>
  <Header.Trailing>{close}</Header.Trailing>
</Header>

<Header className="items-start">
  <Header.Leading>{back}</Header.Leading>
  <Header.Title>{longTitle}</Header.Title>
  <Header.Trailing>{close}</Header.Trailing>
</Header>
Quarterly report for the northern region, including every pending invoice and credit note
Quarterly report for the northern region, including every pending invoice and credit note

Naming a dialog

tsx
<Header as="div" className="border-b-margo border-border">
  <Header.Title id={titleId}>Delete invoice</Header.Title>
</Header>

Reference

proptypedefault
as?ElementType"header"the element or component to render
className?string—added after the component's own class: what you set wins
…restprops of as—typed against the chosen element

Header.Title

proptypedefault
childrenReactNode—the title; clamped to two lines
id?string—for aria-labelledby
className?string—added after the part's own class: what you set wins

Header.Leading and Header.Trailing

proptypedefault
children?ReactNode—what goes on that side
className?string—added after the part's own class: what you set wins