Page header

The top of a page: its title as the page's h1, a line saying what it is, the breadcrumb above it, status beside it, the actions, and the tabs along its foot.

Page header

No script. Folding the secondary actions into a "More" menu (collapseActions) uses a dropdown, which needs Alpine; see getting started. Without it they wrap.

Use it

<x-ds::page-header title="Q3 revenue report" description="Every invoice paid between July and September.">
    <x-slot:breadcrumb>
        <x-ds::breadcrumb>
            <x-ds::breadcrumb-item href="/">Home</x-ds::breadcrumb-item>
            <x-ds::breadcrumb-item href="/reports">Reports</x-ds::breadcrumb-item>
            <x-ds::breadcrumb-item>Q3 revenue</x-ds::breadcrumb-item>
        </x-ds::breadcrumb>
    </x-slot:breadcrumb>

    <x-slot:meta>
        <x-ds::badge tone="success" :dot="true">Published</x-ds::badge>
    </x-slot:meta>

    <x-slot:actions>
        <x-ds::button href="/reports/3/edit">Edit</x-ds::button>
    </x-slot:actions>

    <x-slot:tabs>
        <x-ds::tabs label="Report" :navigation="true">
            <x-ds::tab href="/reports/3" :active="true">Overview</x-ds::tab>
            <x-ds::tab href="/reports/3/invoices" :count="42">Invoices</x-ds::tab>
        </x-ds::tabs>
    </x-slot:tabs>
</x-ds::page-header>

Props

PropTypeDefaultWhat it does
titlestringrequiredThe heading.
ash1 h2 h3h1The heading's level. A header for a section inside a page takes h2.
descriptionstring—A line under the title. The description slot takes markup.
backHrefstring—A back link above the title: for a detail page, or on a phone where a breadcrumb is too long.
backLabelstringBack
secondaryarray[]Secondary actions as data, drawn as secondary buttons before the actions slot. See below.
collapseActionsboolfalseFold secondary into a "More" menu when the header is narrow.
moreLabelstringMore actionsThe More button's name.
truncateboolfalseKeep the title to one line, cut with an ellipsis.
stickyboolfalseStays at the top of the scroll area, on the app's ground (surface-sunken).
stickyOffsetCSS length—With sticky: how far from the top it stops, e.g. 3.5rem under a 3.5rem bar.
borderedboolfalseA rule under the header. A tabs slot draws its own.

Slots: breadcrumb (above the title), meta (beside the title: badges, a status, an avatar group), description, actions (the primary action, and anything else that must always show), tabs.

Secondary actions

Pass them as data, so the header can draw each as a button when there is room and as a menu item when there is not:

<x-ds::page-header title="Invoices" :collapseActions="true" :secondary="[
    ['label' => 'Export', 'href' => route('invoices.export'), 'icon' => 'arrow-down-tray'],
    ['label' => 'Archive all', 'attributes' => ['wire:click' => 'archiveAll']],
    ['label' => 'Delete all', 'tone' => 'danger', 'attributes' => ['wire:click' => 'deleteAll']],
]">
    <x-slot:actions>
        <x-ds::button href="{{ route('invoices.create') }}">New invoice</x-ds::button>
    </x-slot:actions>
</x-ds::page-header>

Each entry takes label, and href or attributes (passed to the button or menu item: wire:click, form, formaction…), with optional icon and tone (danger). Below 36rem of header width (a container query) they fold into a More dropdown; without collapseActions they wrap with the rest.

How it lays out

Side by side when the header is wide: title on the left, actions on the right. When the header narrows below 42rem, the actions drop under the title. It reads its own width, not the window's, so a header in a split pane or beside an open sidebar does the right thing.

A long title wraps by default. With truncate it stays on one line; the whole title is still the heading's text for a screen reader, and shows as a tooltip on hover.

Sticky under a bar

A sticky header stops at the top of the scroll area. Under an app's own sticky bar that is behind the bar, so give it the bar's height:

<x-ds::page-header title="Issues" :sticky="true" stickyOffset="3.5rem" />

Better, set it once in the shell: the header reads --ds-sticky-offset when it has no stickyOffset, so every page inside stops in the right place without knowing what is above it. Both shell blocks do this.

<main class="[--ds-sticky-offset:3.5rem]">{{ $slot }}</main>

Accessibility

  • The title is the page's one h1 (or the level as gives). There should be exactly one h1 on a page.
  • The back link is a link with an arrow and its words.
  • The More button is named by moreLabel; the menu is a dropdown, with its keyboard contract.

Don't

  • Don't put two primary buttons in actions. One primary, the rest secondary.
  • Don't put secondary actions in the slot if you want them to fold. Only secondary folds; the slot always shows.
  • Don't use it as a card title. For a heading inside a panel, use the panel's title.

More in specs/page-header.md.


From the package repo: edit this page on GitHub.

Was this page helpful?