Skip to content

CdsHeader

The header of the application: the title, the global search, notifications, the profile — everything that has to be at hand on any screen. The layout measures its height itself and reserves the space, so the content never ends up under the header.

Storybook GitLab
Test coverage: 100% — good coverage
API in specs
12 / 12 props, events, slots and exposed members with a test
Test cases
21 unit · 0 browser
Code coverage
100% lines · 100% branches measured in v4.0.0-alpha.13
A11y (axe)
6 recommendations in 8 stories measured in v4.0.0-alpha.11

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

NameTypeDefaultDescription
bgColorstring | undefined—Background color of the component
borderedboolean | undefinedfalseShows the border.
colorstring | undefined—Component color
elevatedboolean | undefinedfalseShows the shadow.
heightstring | number | undefined50Height of the element.
modelValueboolean | undefinedtrueVisibility of the element in the layout.
revealboolean | undefinedfalseFloating mode: the element appears/hides on scroll.
revealOffsetnumber | undefined250Scroll threshold (px) up to which the floating element stays visible.
themestring | undefined—Component theme

Events

NameTypeDescription
focusin[event: FocusEvent]Focus moved inside the header.
reveal[value: boolean]Visibility of the floating header has changed.

Slots

NameTypeDescription
defaultanyContent of the header (CdsToolbar and others).