Overview
A toolbar is a layout only. It has no script and no state. Two clusters hold its items: nds-toolbar-start at the leading edge, and nds-toolbar-end at the trailing edge. Each item, such as an Export group or a Filter, connects to its content through its own target attribute. The bar wraps its items onto more lines when they do not fit. To give items a line of their own, wrap each line in nds-toolbar-row.
Pick another component when:
Markup
Variants
The dashed boxes are Content Placeholder items. Put your own items in their place. The box below the bar stands for the content.
| Group | Option | Markup | On element | Use |
|---|---|---|---|---|
| Structure | One line (default) | — | — | Items at the start and at the end. They wrap onto a new line when they do not fit |
| Structure | Rows (hint: Each row takes a line of its own) | canon #toolbar-rows |
— | Each nds-toolbar-row takes a line of its own. Use it when the bar needs more than one line, or to keep some items together on one line at every width |
| Margin | No margin | --toolbar-margin-block: 0 |
.nds-toolbar |
No space above or below the bar. Use it when the parent, such as a card, already sets the space |
Examples
Table Bar
A count and an export group on the first row, a search box on the second, and the applied filters on the third. Manage Records uses the same bar.
| Reference | Entity | Status |
|---|---|---|
| 1041 | Ministry of Interior | Completed |
| 1042 | Ministry of Health | In Review |
| 1043 | Ministry of Education | Pending |
Editor Bar
The toolbar of the Editor.
Built-in Features
-
Leading and Trailing Clusters
The end cluster stays at the trailing edge, also when it wraps onto a line of its own.
-
Search Field Growth
A search box placed straight in the bar or in a row fills the free space on its line. Outside a bar, it is a full-width panel.
-
Empty-Slot Collapse
A cluster or a row whose items are all
hiddentakes no space. An applied-filters row leaves no gap until a filter is applied. -
Bar Text
nds-toolbar-textis block text in the paragraph color. A<b>in it shows in medium weight. It also works outside a bar.
Best Practices
- Put the toolbar directly above the content it controls. Keep the content and its Pagination below the bar, not inside it.
- Put every item in
nds-toolbar-startornds-toolbar-end. A search box is the one exception: it goes straight in the bar or in annds-toolbar-row, where it fills the free space. - Choose a cluster by position, not by job. A table bar usually shows a count, applied filters or a selection summary at the start. It puts Export, a column menu or bulk actions at the end. An editor bar puts its format controls at the start and a source toggle at the end.
- Use
nds-toolbar-rowonly when the bar has two or more rows, or a row and another item. A row that is the bar’s only child changes nothing. For two or three items, use no rows: the bar wraps them itself. - Give the search box most of its line, on a phone above all. Put one control beside it, a Filter or a sort menu, not both. Move the rest to another
nds-toolbar-row.NDS.init.audit()warns about a crowded search line. - Put the applied filters in the toolbar, in their own
nds-toolbar-rowright under the search and filter row, never outside the bar. - Do not crowd one row. Keep closely related items together and move the others to their own row. Small icon buttons can share a row; a wide item, such as a search box or a long count, needs room.
- Use the toolbar on every data screen, so all bars have one layout. A layout made with Grid also works, because each item connects to its content by itself.
- Do not put a toolbar inside another toolbar. Use
nds-toolbar-row: it has the same layout, with no outer margin. - Keep the
hiddenattribute on items that start empty, such as the applied-filters row. Without it, the bar keeps an empty line. - Keep the end cluster to one or two items. Put related buttons in an
nds-btn-group, so they read as one control. - Use one size for every item on a line, buttons and search box alike. A default button is 40px tall, as the search box is, and an
nds-mdbutton is 32px.NDS.init.audit()warns about a line with mixed heights. - Add
data-hidden="sm sr"to a button label to show only the icon on phones. Screen readers still read the label. See Hidden.
API
Classes
| Class | Element | Effect |
|---|---|---|
nds-toolbar |
div above the content |
The bar. It spans the width of its container |
nds-toolbar-row |
div in .nds-toolbar |
Takes a line of its own. Its items have the same layout as the bar’s, with no outer margin |
nds-toolbar-start |
div in .nds-toolbar or .nds-toolbar-row |
The items at the leading edge, var(--spacing-md) apart |
nds-toolbar-end |
div in .nds-toolbar or .nds-toolbar-row |
The items at the trailing edge, var(--spacing-md) apart |
nds-toolbar-text |
span in a cluster, or on its own |
Text such as a record count or a selection summary. nds-results-count is the same class under its first name |
CSS Custom Properties
| Property | Default | Controls |
|---|---|---|
--toolbar-margin-block |
0 var(--spacing-2xl) |
The space above and below the bar, as <above> <below>. Set it on the bar or on a parent |
Tokens
It reads these shared tokens. A change to one also changes other components: see Tokens.
Source: the var() reads in _sass/components/_toolbar.scss.
| Token | Preview | Value |
|---|---|---|
--text-primary-paragraphRead by color | var(--colors-neutral-700)Dark mode var(--colors-neutral-300) |