Skip to main content

Common Examples

import {Toolbar} from "@servicetitan/anvil2";

function ExampleComponent() {
  const selectItems = [
      ...
    ];

  const additionalItems = [
    ...
  ];

  return (
    <Toolbar
      associatedContent="..."
      additionalItems={additionalItems}
      overflow="collapse">
        <Toolbar.Button
          icon={...}
          onClick={...}
          aria-label="..."
        />

        <Toolbar.ButtonToggle
          onClick={...}>
          ...
        </Toolbar.ButtonToggle>

        <Toolbar.ButtonLink
          href={...}>
           ...
        </Toolbar.ButtonLink>

        <Toolbar.Select
          accessibleLabel="..."
          items={selectItems}
          onChange={...} />
    </Toolbar>
  )
}

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.
The components above should be the only items used within a toolbar to ensure look, feel, and overflow interactions remain consistent.

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.
For more guidance on form field labels and context, see input field context association best practices.
Last modified on January 23, 2026