Document commands
Group frequent editing commands into one keyboard navigation region.
Components / Actions
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.
bunx --bun @getweini/cli@latest add toolbarImport 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.
<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.
Group frequent editing commands into one keyboard navigation region.
Combine command buttons, separators, and navigation links.
Arrow keys travel between enabled toolbar controls.
<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.
<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>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.
| Name | Type or signature | Default | What it does |
|---|---|---|---|
orientationprop | ToolbarOrientation | undefined | "horizontal" | Arrange items horizontally or vertically. |
dirprop | "ltr" | "rtl" | undefined | Not set | Set the text direction used for keyboard and layout behavior. |
disabledprop | boolean | undefined | false | Prevent interaction and show the disabled state. |
loopprop | boolean | undefined | true | Wrap keyboard navigation from the last item to the first. |
defaultslot | () => unknown | Required | Content shown inside Toolbar. |
| Name | Type or signature | Default | What 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. |
disabledprop | boolean | undefined | false | Prevent interaction and show the disabled state. |
typeprop | "button" | "submit" | "reset" | undefined | "button" | Choose the native HTML control type or action behavior. |
defaultslot | () => unknown | Required | Content shown inside ToolbarButton. |
elementexposed | HTMLElement | null | — | Reference to the underlying HTML element. |
focusexposed | () => void | undefined | — | Move keyboard focus to this control. |
| Name | Type or signature | Default | What it does |
|---|---|---|---|
hrefprop | string | undefined | Not set | URL to navigate to when this link is activated. |
asprop | Component | "a" | undefined | "a" | Choose the HTML element or Vue component used for this control. |
asChildprop | boolean | undefined | Not set | Use one child element as the control instead of adding another wrapper. |
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. |
disabledprop | boolean | undefined | false | Prevent interaction and show the disabled state. |
defaultslot | () => unknown | Required | Content shown inside ToolbarLink. |
elementexposed | HTMLElement | null | — | Reference to the underlying HTML element. |
focusexposed | () => void | undefined | — | Move keyboard focus to this control. |
| Name | Type or signature | Default | What it does |
|---|---|---|---|
orientationprop | ToolbarOrientation | undefined | Not set | Arrange items horizontally or vertically. |
| Name | Type or signature | Default | What it does |
|---|---|---|---|
disabledprop | boolean | undefined | false | Prevent interaction and show the disabled state. |
defaultslot | () => unknown | Required | Content shown inside ToolbarToggleGroup. |
// 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