Skip to content

Toolbar

A container for grouping a set of buttons and controls.

Usage guidelines

  • Use inputs sparingly: In horizontal toolbars, arrow keys are used both for roving focus and for moving the text cursor inside inputs. Keep inputs to a minimum and place them near the end of the toolbar.

Anatomy

Import the components and assemble their parts:

vue
<script setup>
import {
  ToolbarButton,
  ToolbarGroup,
  ToolbarInput,
  ToolbarLink,
  ToolbarRoot,
  ToolbarSeparator,
} from 'base-ui-vue'
</script>

<template>
  <ToolbarRoot>
    <ToolbarButton />
    <ToolbarLink href="#" />
    <ToolbarSeparator />
    <ToolbarGroup>
      <ToolbarButton />
      <ToolbarButton />
    </ToolbarGroup>
    <ToolbarInput />
  </ToolbarRoot>
</template>

API reference

Root

A container for grouping a set of controls, such as buttons, toggle groups, or menus. Renders a <div> element.

PropTypeDefaultDescription
asstring | Component'div'The element or component to use for the root node.
disabledbooleanfalseWhether the component is disabled.
orientation'horizontal' | 'vertical''horizontal'The orientation of the toolbar.
loop-focusbooleantrueIf true, using keyboard navigation will wrap focus to the other end of the toolbar once the end is reached.
classstring | ((state: State) => string)undefinedCSS class applied to the element, or a function that returns a class based on the component state.
styleStyleValue | ((state: State) => StyleValue)undefinedStyle applied to the element, or a function that returns a style object based on the component state.
AttributeDescription
data-disabledPresent when the toolbar is disabled.
data-orientationIndicates the toolbar orientation.

Button

A button that can be used as-is or as a trigger for other components. Renders a <button> element.

PropTypeDefaultDescription
asstring | Component'button'The element or component to use for the root node.
disabledbooleanfalseWhether the component is disabled.
focusable-when-disabledbooleantrueWhether the component remains focusable when disabled.
native-buttonbooleantrueWhether the component is being rendered as a native button.
classstring | ((state: State) => string)undefinedCSS class applied to the element, or a function that returns a class based on the component state.
styleStyleValue | ((state: State) => StyleValue)undefinedStyle applied to the element, or a function that returns a style object based on the component state.
AttributeDescription
data-disabledPresent when the button is disabled.
data-focusablePresent when the button remains focusable while disabled.
data-orientationIndicates the toolbar orientation.

A link component. Renders an <a> element.

PropTypeDefaultDescription
asstring | Component'a'The element or component to use for the root node.
classstring | ((state: State) => string)undefinedCSS class applied to the element, or a function that returns a class based on the component state.
styleStyleValue | ((state: State) => StyleValue)undefinedStyle applied to the element, or a function that returns a style object based on the component state.
AttributeDescription
data-orientationIndicates the toolbar orientation.

Input

A native input element that integrates with Toolbar keyboard navigation. Renders an <input> element.

PropTypeDefaultDescription
asstring | Component'input'The element or component to use for the root node.
disabledbooleanfalseWhether the component is disabled.
focusable-when-disabledbooleantrueWhether the component remains focusable when disabled.
default-valuestring | numberundefinedThe initial input value.
classstring | ((state: State) => string)undefinedCSS class applied to the element, or a function that returns a class based on the component state.
styleStyleValue | ((state: State) => StyleValue)undefinedStyle applied to the element, or a function that returns a style object based on the component state.
AttributeDescription
data-disabledPresent when the input is disabled.
data-focusablePresent when the input remains focusable while disabled.
data-orientationIndicates the toolbar orientation.

Group

Groups several toolbar items or toggles. Renders a <div> element.

PropTypeDefaultDescription
asstring | Component'div'The element or component to use for the root node.
disabledbooleanfalseWhether all toolbar items in the group are disabled.
classstring | ((state: State) => string)undefinedCSS class applied to the element, or a function that returns a class based on the component state.
styleStyleValue | ((state: State) => StyleValue)undefinedStyle applied to the element, or a function that returns a style object based on the component state.
AttributeDescription
data-disabledPresent when the group is disabled.
data-orientationIndicates the toolbar orientation.

Separator

A separator element accessible to screen readers. Renders a <div> element.

PropTypeDefaultDescription
asstring | Component'div'The element or component to use for the root node.
orientation'horizontal' | 'vertical'undefinedThe orientation of the separator. Defaults to the opposite of the toolbar orientation when not provided.
classstring | ((state: State) => string)undefinedCSS class applied to the element, or a function that returns a class based on the component state.
styleStyleValue | ((state: State) => StyleValue)undefinedStyle applied to the element, or a function that returns a style object based on the component state.
AttributeDescription
data-orientationIndicates the orientation of the separator.