Layout & Containers
Page Header
The top of a page: a breadcrumb, the title with a line about it, and the page's actions in one row.
Start every page of an app with a page header, so the title, where the page sits and what can be done on it are always in the same place. On a wide screen the actions sit to the right of the title; on a phone they move under it.
Preview
Section titled “Preview”<nana-page-header
heading="Motor claims"
description="Claims filed against motor policies this month, newest first."
divider
style="width: 100%"
>
<nana-breadcrumb slot="breadcrumb">
<nana-breadcrumb-item href="#">Home</nana-breadcrumb-item>
<nana-breadcrumb-item href="#">Claims</nana-breadcrumb-item>
<nana-breadcrumb-item>Motor</nana-breadcrumb-item>
</nana-breadcrumb>
<nana-button slot="actions" variant="secondary">Export</nana-button>
<nana-button slot="actions">New claim</nana-button>
</nana-page-header> <script lang="ts">
import { NanaBreadcrumb, NanaButton, NanaPageHeader } from '$lib';
const trail = [{ label: 'Home', href: '#' }, { label: 'Claims', href: '#' }, { label: 'Motor' }];
</script>
<div class="w-full">
<NanaPageHeader
heading="Motor claims"
description="Claims filed against motor policies this month, newest first."
divider
>
{#snippet breadcrumb()}
<NanaBreadcrumb items={trail} />
{/snippet}
{#snippet actions()}
<NanaButton variant="secondary">Export</NanaButton>
<NanaButton>New claim</NanaButton>
{/snippet}
</NanaPageHeader>
</div> Installation
Section titled “Installation”Install the package for a versioned dependency:
npm install @nana-tec/ui-componentsOr copy the source in and own it:
npx @nana-tec/ui add page-header --framework web-componentsnpx @nana-tec/ui add page-header --framework svelteLands in src/lib/components/ui/page-header/ as NanaPageHeader.svelte, styled with
Tailwind classes that resolve to the design tokens. Requires Tailwind v4.
Import the autoloader once, in your app's entry point. Every <nana-*> tag then works anywhere, and
each component downloads only the first time a page uses it:
import "@nana-tec/ui-components/autoloader";import "@nana-tec/ui-components/theme";The second line gives every component the Nana look and the design tokens behind it. Leave it out to style the components entirely yourself.
Import a component directly when it must be ready at once: on screen at first paint, or when you call its methods straight away. The two mix freely:
import "@nana-tec/ui-components/page-header";
Copied in with npx @nana-tec/ui add page-header? Import your project's own
@/lib/nana-ui/autoloader.js once instead; the CLI keeps it up to date.
Give the header a heading and, if it helps, a description. Put a breadcrumb in the
breadcrumb slot and buttons in the actions slot. Anything else, such as tabs or
filters, goes in the default slot under the title row.
<nana-page-header heading="Claims" description="Every claim filed this month."> <nana-breadcrumb slot="breadcrumb">…</nana-breadcrumb> <nana-button slot="actions">New claim</nana-button> <nana-tab-group>…</nana-tab-group></nana-page-header>For a title with markup, such as a reference number in bold, use the heading slot
instead of the property. The description slot works the same way.
Give the header a heading and, if it helps, a description, as text or as a snippet.
The breadcrumb and actions snippets fill their places; children go under the title
row, for tabs or filters.
<script lang="ts"> import { NanaPageHeader } from '$lib/components/ui/page-header';</script>
<NanaPageHeader heading="Claims" description="Every claim filed this month."> {#snippet breadcrumb()}<NanaBreadcrumb items={trail} />{/snippet} {#snippet actions()}<NanaButton>New claim</NanaButton>{/snippet} <NanaTabs …></NanaTabs></NanaPageHeader>Any part left out takes no space.
Heading level
Section titled “Heading level”The title is a level-one heading, since it names the page. A header for a part of a page,
such as a settings panel, takes level 2 or 3, which also makes the title smaller.
Divider
Section titled “Divider”Set divider to draw a line under the header, when the content below starts without a
border of its own.
Accessibility
Section titled “Accessibility”- Use one level-one page header per page, so the title is the page’s main heading.
- Keep the actions to two or three. Move the rest into a menu, so the row does not wrap on a small screen.
- Name the breadcrumb, for example
aria-label="Breadcrumb"; Nana’s breadcrumb does this for you.
Properties
| Property | Attribute | Type | Default | Description |
|---|---|---|---|---|
description | description | string | '' | A short line under the title. |
divider | divider | boolean | false | Draws a line under the header. |
heading | heading | string | '' | The page title. |
level | level | number | 1 | Heading level of the title: 1 for the page, 2 or 3 for a header inside it. |
Slots
| Slot | Description |
|---|---|
(default) | Content under the title row, such as tabs or filters |
breadcrumb | A nana-breadcrumb above the title |
heading | Rich title content, in place of the heading property |
description | Rich description content, in place of the description property |
actions | Buttons for the page, such as Export or New |
CSS parts
| Part | Description |
|---|---|
::part(base) | The header container |
::part(breadcrumb) | The wrapper around the breadcrumb |
::part(row) | The row holding the title and the actions |
::part(heading) | The page title |
::part(description) | The line under the title |
::part(actions) | The wrapper around the actions |
::part(content) | The wrapper around the content under the row |
CSS custom properties
| Property | Description |
|---|---|
--nana-page-header-gap | Space between the breadcrumb, the row and the content |
NanaPageHeader
| Prop | Type | Default |
|---|---|---|
id | string | uid('nana-page-header') |
headingrequired | Text | |
description | Text | |
level | PageHeaderLevel | 1 |
divider | boolean | false |
breadcrumb | Snippet | |
actions | Snippet | |
children | Snippet |
Also accepts Omit<HTMLAttributes<HTMLElement>, 'class' | 'id'>.
heading is required; it and description take text or a snippet. level is 1, 2 or 3.
divider draws the line underneath. breadcrumb and actions are snippets, and children
render under the title row.