Skip to content

CdsToolbar

A horizontal bar with a title and actions: it fills the header and the footer of the application, and on a page it assembles the title of a section together with its buttons. CdsToolbarTitle stretches and pushes the left and the right groups to the edges on its own.

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

The toolbar only lays the content out — the place in the layout is reserved by CdsHeader and CdsFooter. For navigating the subsections take CdsTabs; for an action bar over a record take CdsButtonGroup.

Anatomy ​

The toolbar lines the content up in a row and centers it vertically. The CdsToolbarTitle title takes all the free space, so the elements before it stick to the left edge and the ones after it stick to the right.

Variations ​

Title ​

CdsToolbarTitle stretches and truncates long text with an ellipsis without breaking the line. The shrink prop turns the stretching off: the title shrinks to its content and stays next to the neighboring element — a handy way to put a status or a counter right after the name.

Paddings ​

The no-gutters prop removes the inner paddings entirely — the toolbar aligns with the content of the page. The no-gutter prop removes the padding on one side: start or end. The inset prop does the opposite and adds a padding on the left — that is how a nested second-level toolbar is set off.

Separator and color ​

The bordered prop draws the bottom border — it separates the title of a section from its content. The bg-color and color props paint the background and the text. Inside CdsHeader and CdsFooter the toolbar does not draw its own background: the color comes from the part of the layout, so the bar does not cover it.

Guidelines ​

Scenarios ​

Section title on a page ​

The name, the status and the actions in a single row: shrink keeps the status next to the name, mr-auto pushes the buttons to the right edge, no-gutters aligns the toolbar with the content of the card, and bordered separates the header of the section from the text.

In CdsHeader the toolbar holds the menu button, the title and the profile; in CdsFooter it holds the copyright. The background is set on the parts of the layout, and the toolbar inherits it together with the contrasting text color.

API ​

CdsToolbar ​

Props

NameTypeDefaultDescription
bgColorstring | undefined—Background color of the component
borderedboolean | undefinedfalseShows the bottom border.
colorstring | undefined—Component color
insetboolean | undefinedfalseNested toolbar (indented from the left).
noGutter"start" | "end" | undefined—Removes the padding on one side: start or end.
noGuttersboolean | undefinedfalseRemoves all inner paddings.
themestring | undefined—Component theme

Slots

NameTypeDescription
defaultanyContent of the toolbar.

CdsToolbarTitle ​

Props

NameTypeDefaultDescription
shrinkboolean | undefinedfalseShrinks the title to its content instead of stretching it.

Slots

NameTypeDescription
defaultanyText of the title.