PageHeader
Place a page title, subtitle, back button, breadcrumbs, and right-aligned actions at the top of a page.
Import
import { HuiPageHeader } from '@nscode/handy-ui'
Basic Usage
title is the page heading, and subtitle appears to its right. Either can be used independently.
<template>
<HuiSpace direction="vertical" fill>
<HuiPageHeader title="User management" subtitle="Manage all users in the system" />
<HuiPageHeader title="Title only" />
</HuiSpace>
</template>
Back Button
show-back=true displays a back button to the left of the title. Clicking it, or pressing Enter/Space while focused, emits back. The component does not navigate automatically; handle the event, for example by calling the router's back(). The example below shows feedback instead of navigating. back-icon accepts an HuiIcon name, defaulting to arrow-left.
<script setup lang="ts">
import { ref } from 'vue'
import { HuiMessage, HuiPageHeader, HuiSpace } from '@nscode/handy-ui'
const backCount = ref(0)
// Navigate here in an application, for example with router.back()
const handleBack = () => {
backCount.value += 1
HuiMessage.info('back event emitted')
}
</script>
<template>
<HuiSpace direction="vertical" fill>
<HuiPageHeader
title="User details"
subtitle="Default icon: arrow-left"
show-back
@back="handleBack"
/>
<HuiPageHeader
title="Edit user"
subtitle="Icon: chevron-left"
show-back
back-icon="chevron-left"
@back="handleBack"
/>
<HuiPageHeader
title="Orders"
subtitle="Icon: double-left"
show-back
back-icon="double-left"
@back="handleBack"
/>
</HuiSpace>
<p style="margin-top: 12px">back emitted {{ backCount }} times</p>
</template>
Icons
icon displays an HuiIcon before the title. When a back button is present, the icon appears to its right.
<template>
<HuiSpace direction="vertical" fill>
<HuiPageHeader title="System settings" icon="setting" />
<HuiPageHeader title="Member management" subtitle="32 members" icon="users" />
<HuiPageHeader title="File details" icon="folder" show-back />
</HuiSpace>
</template>
Breadcrumbs and Actions
The breadcrumb slot occupies its own row at the top. extra appears on the far right of the title row and wraps when space is limited. Use HuiSpace to separate multiple buttons in extra.
<script setup lang="ts">
import {
HuiPageHeader,
HuiBreadcrumb,
HuiBreadcrumbItem,
HuiButton,
HuiSpace
} from '@nscode/handy-ui'
</script>
<template>
<HuiPageHeader title="User management" subtitle="128 users">
<template #breadcrumb>
<HuiBreadcrumb>
<HuiBreadcrumbItem to="/">Home</HuiBreadcrumbItem>
<HuiBreadcrumbItem to="/system">System management</HuiBreadcrumbItem>
<HuiBreadcrumbItem>User management</HuiBreadcrumbItem>
</HuiBreadcrumb>
</template>
<template #extra>
<HuiSpace>
<HuiButton icon="upload">Import</HuiButton>
<HuiButton icon="download">Export</HuiButton>
<HuiButton type="primary" icon="plus">Add user</HuiButton>
</HuiSpace>
</template>
</HuiPageHeader>
</template>
Footer and Content
The footer slot appears below the title row, often for tabs. The default slot appears below footer, for content such as a description.
<script setup lang="ts">
import { ref } from 'vue'
import { HuiPageHeader, HuiTabs, HuiTabPane } from '@nscode/handy-ui'
const activeTab = ref<string | number>('basic')
</script>
<template>
<HuiPageHeader title="Order details" show-back>
<template #footer>
<HuiTabs v-model="activeTab">
<HuiTabPane name="basic" label="Basic information" />
<HuiTabPane name="log" label="Action history" />
</HuiTabs>
</template>
<p style="margin: 0; color: var(--hui-text-color-secondary)">Order number: 20261117001</p>
</HuiPageHeader>
</template>
Custom Titles
The title and subtitle slots accept content beyond plain text. Providing a slot replaces the corresponding prop.
<script setup lang="ts">
import { HuiPageHeader, HuiTag } from '@nscode/handy-ui'
</script>
<template>
<HuiPageHeader>
<template #title>
Project A
<HuiTag type="success" style="margin-left: 8px">In progress</HuiTag>
</template>
<template #subtitle>Owner: 李四</template>
</HuiPageHeader>
</template>
Ghost Mode
ghost=true removes the background and bottom border, reduces vertical padding, and removes horizontal padding. It is useful inside a container that already has a background. The two headers below share the same gray container styling; the second uses ghost mode:
<template>
<HuiSpace direction="vertical" fill>
<div class="box">
<HuiPageHeader title="Overview" subtitle="Normal header" />
</div>
<div class="box">
<HuiPageHeader title="Overview" subtitle="ghost" ghost />
</div>
</HuiSpace>
</template>
<style scoped>
.box {
padding: var(--hui-spacing-4);
background-color: var(--hui-bg-color-page);
border-radius: var(--hui-border-radius);
}
</style>
Complete Example
Combine breadcrumbs, the back button, an icon, title, subtitle, actions, footer tabs, and content:
<script setup lang="ts">
import { ref } from 'vue'
import {
HuiBreadcrumb,
HuiBreadcrumbItem,
HuiButton,
HuiMessage,
HuiPageHeader,
HuiSpace,
HuiTabPane,
HuiTabs,
HuiTag
} from '@nscode/handy-ui'
const activeTab = ref<string | number>('detail')
const handleBack = () => {
HuiMessage.info('Return to the previous page')
}
</script>
<template>
<HuiPageHeader icon="file" show-back @back="handleBack">
<template #breadcrumb>
<HuiBreadcrumb>
<HuiBreadcrumbItem to="/">Home</HuiBreadcrumbItem>
<HuiBreadcrumbItem to="/contract">Contract management</HuiBreadcrumbItem>
<HuiBreadcrumbItem>Contract details</HuiBreadcrumbItem>
</HuiBreadcrumb>
</template>
<template #title>
HT-2026-0018
<HuiTag type="warning" style="margin-left: 8px">Pending approval</HuiTag>
</template>
<template #subtitle>Purchase contract</template>
<template #extra>
<HuiSpace>
<HuiButton icon="edit">Edit</HuiButton>
<HuiButton type="danger" variant="outline">Reject</HuiButton>
<HuiButton type="primary" icon="check">Approve</HuiButton>
</HuiSpace>
</template>
<template #footer>
<HuiTabs v-model="activeTab">
<HuiTabPane name="detail" label="Contract information" />
<HuiTabPane name="attachment" label="Attachments" />
<HuiTabPane name="history" label="Approval history" />
</HuiTabs>
</template>
<p style="margin: 0; color: var(--hui-text-color-secondary)">
Current tab: {{ activeTab }}. Created by: 王五, on 2026-11-10.
</p>
</HuiPageHeader>
</template>
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| title | string | - | Title; replaced by the title slot when provided |
| subtitle | string | - | Subtitle; replaced by the subtitle slot when provided |
| icon | string | - | Icon name before the title (HuiIcon's name) |
| showBack | boolean | false | Whether to show the back button |
| backIcon | string | 'arrow-left' | Back button icon (HuiIcon's name) |
| ghost | boolean | false | Whether to remove the background and bottom border |
Events
| Event | Callback arguments | Description |
|---|---|---|
| back | - | Emitted when the back button is clicked or activated with Enter/Space while focused |
Slots
| Slot | Scope arguments | Description |
|---|---|---|
| default | - | Content at the bottom, below footer |
| breadcrumb | - | Breadcrumbs at the top, occupying their own row |
| title | - | Title content, replacing the title prop |
| subtitle | - | Subtitle content, replacing the subtitle prop |
| extra | - | Actions on the far right of the title row |
| footer | - | Footer below the title row and above the content |
Types
import type { PageHeaderProps, PageHeaderEmits } from '@nscode/handy-ui'
interface PageHeaderProps {
title?: string
subtitle?: string
icon?: string
showBack?: boolean
backIcon?: string
ghost?: boolean
}
interface PageHeaderEmits {
back: []
}