Skip to main content

Common Examples

Toolbar Components

The Anvil2 toolbar is made up a main Toolbar component and a few sub-components that can be used together to build simple or complex bars.
  • Toolbar: The parent component to configure toolbars.
  • Toolbar.Button: Used to create simple actions that need to be triggered via a button such as opening up a dialog.
  • Toolbar.ButtonToggle: Used to create simple actions that rely on a boolean response such as text font styles for a rich text editor.
  • Toolbar.ButtonLink: Used to create links to other sources such as download links.
  • Toolbar.Select: Used to create a single select drop down for items such as heading size selection for a rich text editor.
  • Toolbar.Search Beta: Used to create a search input field for filtering or searching content.
The components above should be the only items used within a toolbar to ensure look, feel, and overflow interactions remain consistent.

Using Toolbar.Search Beta

The Toolbar.Search component provides a search input field for filtering or searching content within the context of a toolbar.

React Accessibility

  • Keyboard interaction and aria guideline to follow WCAG Toolbar pattern.
  • For controls that have the option to be icon only in view, aria-labels are required.
  • The Toolbar component has a required prop of associatedContent to properly populate an aria-label for the component itself.
  • Toolbar.Select has an accessibleLabel prop to properly link the list of select items to the trigger.
  • Toolbar.Search uses a search input with a clear button that is keyboard accessible via arrow keys.
For more guidance on form field labels and context, see input field context association best practices.

Testing

The toolbar’s leaf controls, overflow menu, and (in beta) search field carry a stable data-anv-part attribute so end-to-end tests can target them directly. The library owns the part names; you supply the instance identifier.Attach your own data-* attribute (such as data-cy or data-testid) to the Toolbar. It is forwarded to the root element, letting you scope queries to a single instance:
Collapsed overflow items also carry data-id matching the item’s id, so you can target a specific row with [data-anv-part="overflow-item"][data-id="…"]. Discriminate repeated item parts with aria-label, id, or a consumer data-* on the leaf control.Toolbar.ButtonLink and Toolbar.Select do not receive a library item part yet — pass your own data-* attributes on those components when you need to target them. Callers may override item (for example, FilterBar stamps trigger on boolean toggles).
The overflow menu renders in the browser’s top layer (menu and overflow-item parts), outside the Toolbar root. Descendant queries scoped to your wrapper attribute will not match those parts after the menu opens. Target them by their part attribute directly. Only one overflow menu is open at a time.
Last modified on August 5, 2026