Skip to content

Search documentation

Search guides, examples, and component APIs.

Quick links
↑↓ NavigateEnter OpenEsc Close
Get started

Documentation navigation

Components / Actions

Toolbar

A roving-focus group for buttons, links, separators, and toggle groups.

Last changed in version 0.14.2: Improve keyboard navigation, action feedback, and selected colors across Vue components.

Interactive showcase

Install

Run in your project
bunx --bun @getweini/cli@latest add toolbar

Start with this example

Import the files copied by the install command, then place the component in your Vue template. The text and values in the example belong to your app; change them to fit your task.

Vue
<script setup lang="ts">
import Toolbar from './components/ui/toolbar/Toolbar.vue'
import ToolbarButton from './components/ui/toolbar/ToolbarButton.vue'
import ToolbarSeparator from './components/ui/toolbar/ToolbarSeparator.vue'
</script>
<template>
  <Toolbar aria-label="Editor commands">
    <ToolbarButton @click="$emit('undo')">Undo</ToolbarButton>
    <ToolbarButton @click="$emit('redo')">Redo</ToolbarButton>
    <ToolbarSeparator />
    <ToolbarButton @click="$emit('save')">Save</ToolbarButton>
  </Toolbar>
</template>

Arrow keys follow orientation and direction; Home and End reach the edges and disabled controls are skipped.

When to use it

Document commands

Group frequent editing commands into one keyboard navigation region.

Mixed controls

Combine command buttons, separators, and navigation links.

More examples

Editor toolbar

Arrow keys travel between enabled toolbar controls.

Editor toolbar
<script setup lang="ts">
import Toolbar from './components/ui/toolbar/Toolbar.vue'
import ToolbarButton from './components/ui/toolbar/ToolbarButton.vue'
import ToolbarSeparator from './components/ui/toolbar/ToolbarSeparator.vue'
</script>
<template>
  <Toolbar aria-label="Editor commands">
    <ToolbarButton @click="$emit('undo')">Undo</ToolbarButton>
    <ToolbarButton @click="$emit('redo')">Redo</ToolbarButton>
    <ToolbarSeparator />
    <ToolbarButton @click="$emit('save')">Save</ToolbarButton>
  </Toolbar>
</template>

A ToolbarLink keeps native link navigation.

Actions and link
<script setup lang="ts">
import Toolbar from './components/ui/toolbar/Toolbar.vue'
import ToolbarButton from './components/ui/toolbar/ToolbarButton.vue'
import ToolbarLink from './components/ui/toolbar/ToolbarLink.vue'
</script>
<template>
  <Toolbar aria-label="Project controls">
    <ToolbarButton variant="ghost" @click="$emit('refresh')">Refresh</ToolbarButton>
    <ToolbarLink href="/projects/history" variant="ghost">History</ToolbarLink>
  </Toolbar>
</template>

Complete API

Every public prop, model, event, slot, and exposed member of the installed Vue parts is listed below. “Not set” means you can leave that value out; “Required” means you must provide it. Native HTML attributes also work where the component uses a native element.

Toolbar

Complete API for Toolbar
NameType or signatureDefaultWhat it does
orientationpropToolbarOrientation | undefined"horizontal"Arrange items horizontally or vertically.
dirprop"ltr" | "rtl" | undefinedNot setSet the text direction used for keyboard and layout behavior.
disabledpropboolean | undefinedfalsePrevent interaction and show the disabled state.
looppropboolean | undefinedtrueWrap keyboard navigation from the last item to the first.
defaultslot() => unknownRequiredContent shown inside Toolbar.

ToolbarButton

Complete API for ToolbarButton
NameType or signatureDefaultWhat it does
sizeprop"sm" | "md" | "lg" | undefined"md"Choose the visual size. Medium is the usual default where available.
variantprop"default" | "outline" | "ghost" | undefined"ghost"Choose the visual treatment for this component.
disabledpropboolean | undefinedfalsePrevent interaction and show the disabled state.
typeprop"button" | "submit" | "reset" | undefined"button"Choose the native HTML control type or action behavior.
defaultslot() => unknownRequiredContent shown inside ToolbarButton.
elementexposedHTMLElement | null—Reference to the underlying HTML element.
focusexposed() => void | undefined—Move keyboard focus to this control.
Complete API for ToolbarLink
NameType or signatureDefaultWhat it does

ToolbarSeparator

Complete API for ToolbarSeparator
NameType or signatureDefaultWhat it does
orientationpropToolbarOrientation | undefinedNot setArrange items horizontally or vertically.

ToolbarToggleGroup

Complete API for ToolbarToggleGroup
NameType or signatureDefaultWhat it does
disabledpropboolean | undefinedfalsePrevent interaction and show the disabled state.
defaultslot() => unknownRequiredContent shown inside ToolbarToggleGroup.
Public type definitions
Public types
// packages/frameworks/vue/components/toolbar/types.ts
// ------- IMPORTS -------

import type { Component } from 'vue'
import type { toolbarSizes, toolbarVariants } from './styles'

// ------- TYPES -------

export type ToolbarOrientation = 'horizontal' | 'vertical'

export interface ToolbarProps {
  orientation?: ToolbarOrientation
  dir?: 'ltr' | 'rtl'
  disabled?: boolean
  loop?: boolean
}

export interface ToolbarButtonProps {
  size?: keyof typeof toolbarSizes
  variant?: keyof typeof toolbarVariants
  disabled?: boolean
  type?: 'button' | 'submit' | 'reset'
}

export interface ToolbarLinkProps {
  href?: string
  as?: 'a' | Component
  asChild?: boolean
  size?: keyof typeof toolbarSizes
  variant?: keyof typeof toolbarVariants
  disabled?: boolean
}

export interface ToolbarSeparatorProps {
  orientation?: ToolbarOrientation
}

export interface ToolbarToggleGroupProps {
  disabled?: boolean
}


// packages/frameworks/vue/components/toolbar/styles.ts
export const toolbarSizes = {
  sm: 'h-8 min-w-8 px-2 text-xs',
  md: 'h-10 min-w-10 px-3 text-sm',
  lg: 'h-12 min-w-12 px-4 text-base',
} as const

export const toolbarVariants = {
  default: 'bg-primary text-primary-foreground hover:bg-primary-hover',
  outline:
    'border border-control-border bg-clip-padding bg-control text-foreground hover:bg-secondary',
  ghost: 'text-foreground hover:bg-secondary',
} as const

Implementation notes

  • When dir is omitted, keyboard navigation uses the rendered element’s computed direction.
  • The toolbar offers one tab stop; arrows, Home, and End move among enabled children.
  • ToolbarToggleGroup integrates an existing ToggleGroup while preserving its internal arrow behavior.
  • Toolbar buttons and links give slight press feedback while enabled.

Accessibility and localization

  • Use a specific aria-label for each toolbar.
  • An icon-only child still needs an application-provided accessible name.

Source contract and editing guidance