Toolbar
Group controls for a related set of actions.
Demos
Size
Usage
vue
<script setup lang="ts">
import { Accordion } from '~/components/ui/accordion'
const items = [
{ value: 'source', label: 'Do I own the source?', content: 'Yes. Copy and adapt the files.' },
]
</script>
<template>
<Accordion :items="items" />
</template>
Installation
Complete the shared installation. Copy Toolbar.vue and index.ts into app/components/ui/toolbar/.
app/components/ui/toolbar/Toolbar.vue
<script setup lang="ts">
import { AlertDialog as Primitive } from 'akaza-ui'
import { computed, useAttrs, useTemplateRef } from 'vue'
import { cn } from '../../../utils/ui'
import uiConfig from '../ui.config'
import {
alertDialogVariants,
resolveAlertDialogVariants,
type AlertDialogProps,
type AlertDialogSlots,
} from './index'
defineOptions({ inheritAttrs: false })
// Preserve Akaza defaults when optional props, including Boolean aliases, are omitted.
const props = withDefaults(defineProps<AlertDialogProps>(), {
as: undefined,
teleport: undefined,
transition: undefined,
duration: undefined,
title: undefined,
ariaLabel: undefined,
description: undefined,
ui: undefined,
modelValue: undefined,
})
defineSlots<AlertDialogSlots>()
const attrs = useAttrs()
const styles = computed(() => alertDialogVariants(resolveAlertDialogVariants(props, uiConfig)))
const mergedUi = computed(() => {
const overrides = props.ui as Record<string, string | undefined> | undefined
return Object.fromEntries(
Object.entries(styles.value).map(([part, style]) => [
part,
cn(style(), overrides?.[part], part === 'content' ? props.class : undefined),
]),
)
})
const primitiveProps = computed(() => {
const { class: _class, ui: _ui, width: _width, ...native } = props
return native
})
const primitive = useTemplateRef<InstanceType<typeof Primitive>>('primitive')
defineExpose({
get open() {
return primitive.value!.open
},
get close() {
return primitive.value!.close
},
get toggle() {
return primitive.value!.toggle
},
get titleId() {
return primitive.value!.titleId
},
get descriptionId() {
return primitive.value!.descriptionId
},
})
</script>
<template>
<component
:is="Primitive"
ref="primitive"
v-bind="{ ...primitiveProps, ...attrs }"
:ui="mergedUi"
>
<template v-for="(_, name) in $slots" #[name]="scope"
><slot :name="name as keyof AlertDialogSlots" v-bind="scope ?? {}"
/></template>
</component>
</template>
API
Variants and defaults
| Prop | Values | Default |
|---|---|---|
size | xs, sm, md, lg, xl | sm |
Props
| Prop | Type | Default | Description |
|---|---|---|---|
items | ToolbarItem[] | [] | Generated toolbar items. |
orientation | "horizontal" | "vertical" | "horizontal" | Toolbar orientation. |
loop | boolean | true | Arrow focus wraps. |
disabled | boolean | false | Disables generated items. |
ariaLabel | string | — | Accessible label. |
ariaLabelledby | string | — | Accessible label id. |
ui | ToolbarUi | — | Classes for structural parts. |
Slots
| Slot | Props | Description |
|---|---|---|
default | — | Extra toolbar content after generated items. |
[item.slot] | item, isDisabled | Custom generated item content. |
Events
| Event | Payload | Description |
|---|---|---|
select | (item, details) | Fired before an item runs onSelect. |
input-change | (item, value, details) | Fired before a generated input runs onUpdateValue. |
Keyboard
| Key | Behavior |
|---|---|
ArrowRight / ArrowLeft | Move focus in horizontal toolbar. |
ArrowDown / ArrowUp | Move focus in vertical toolbar. |
Home / End | Move to first/last focusable item. |
Generated buttons and links use one roving tab stop. Text inputs remain native tab stops and keep Arrow/Home/End cursor behavior; toolbar navigation never hijacks their editing keys.