The header works only inside CdsLayout — outside the layout it renders nothing and warns about it in the console. The content of the header is laid out by CdsToolbar, and the bottom bar of the application is built by CdsFooter.
Variations
Separator
The header overlaps the scrollable content, so its edge is worth marking: bordered draws a border, elevated casts a shadow. The shadow is more noticeable and suits long lists better, the border suits calm pages.
Height
The height comes from the content: the layout measures the header and reserves exactly as much space as it takes. The height prop is an initial estimate before the first measurement: set the expected height so the content does not jump on mount.
Color
The bg-color prop paints the background of the header with a palette alias, color paints the text and the icons inside. If only the background is set, the text color is picked to be contrasting automatically.
Floating mode
The reveal prop hides the header when scrolling down and brings it back when scrolling up — on long lists this gives the screen to the content. The reveal-offset prop sets the zone near the top of the page where the header stays in place. The @reveal event reports the change of visibility, and moving the keyboard focus inside a hidden header brings it back.
Visibility
The model-value prop removes the header entirely: the layout stops reserving space for it and the content takes the freed height. This is a handy way to hide the header in full-screen modes — document viewing, a presentation.
Guidelines
Scenarios
Application header
The basic set: a menu button, a logo, the title in CdsToolbarTitle and the actions on the right. CdsToolbarTitle stretches and pushes the left and the right groups to the edges, so no extra spacers are needed.
Header with tabs
Two CdsToolbar components in a row turn the header into a two-level one: the name of the section on top, CdsTabs with the subsections below. The tabs stay on the screen together with the header, so you can switch from any point of the list.
API
Props
| Name | Type | Default | Description |
|---|---|---|---|
bgColor | string | undefined | — | Background color of the component |
bordered | boolean | undefined | false | Shows the border. |
color | string | undefined | — | Component color |
elevated | boolean | undefined | false | Shows the shadow. |
height | string | number | undefined | 50 | Height of the element. |
modelValue | boolean | undefined | true | Visibility of the element in the layout. |
reveal | boolean | undefined | false | Floating mode: the element appears/hides on scroll. |
revealOffset | number | undefined | 250 | Scroll threshold (px) up to which the floating element stays visible. |
theme | string | undefined | — | Component theme |
Events
| Name | Type | Description |
|---|---|---|
focusin | [event: FocusEvent] | Focus moved inside the header. |
reveal | [value: boolean] | Visibility of the floating header has changed. |
Slots
| Name | Type | Description |
|---|---|---|
default | any | Content of the header (CdsToolbar and others). |