GhostToolbar reference
Package: @ghostvue/vue. Status: experimental (stability policy).
Headless APG toolbar container. useGhostToolbar owns role and orientation semantics; useRovingFocus moves among focusable slot children. Themed flex layout lives on @ghostvue/themes.
Generated from the component manifest. Edit the manifest or Vue source, then rebuild the docs.
Props
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
as | GhostToolbarElement | "div" | No | Root element tag for the toolbar container. |
dir | GhostToolbarDirection | — | No | Optional text direction for horizontal arrow reversal in RTL. |
label | string | — | No | Accessible name via aria-label when a visible label element is not used. |
loop | boolean | true | No | Wrap arrow and Home/End movement from last enabled item to first. |
orientation | GhostToolbarOrientation | "horizontal" | No | Toolbar layout and roving arrow axis. Sets aria-orientation when vertical. |
Emits
None declared.
Models
None declared.
Slots
| Name | Description |
|---|---|
default | Toolbar items such as GhostButton, GhostSwitch, and GhostSeparator. |
Slot props: default
None declared.
Exposed members
| Name | Type | Description |
|---|---|---|
blur | () => void | Exposed method `blur`. |
element | HTMLElement | null | Root element after mount; null before mount. |
focus | (options?: FocusOptions) => void | Exposed method `focus`. |
Parts and data attributes
| Attribute | Value | Description |
|---|---|---|
data-part | root | Toolbar container with role=toolbar. |
data-orientation | horizontal, vertical | Resolved orientation on the root. Always present. |
CSS variables
None declared.
Accessibility
Role: toolbar. APG pattern: https://www.w3.org/WAI/ARIA/apg/patterns/toolbar/.
Required ARIA attributes: aria-label.
Keyboard
| Key | Action | Automated browser test |
|---|---|---|
ArrowLeft | Previous enabled item when orientation is horizontal (flipped in RTL). | Not reviewed |
ArrowRight | Next enabled item when orientation is horizontal (flipped in RTL). | Not reviewed |
ArrowUp | Previous enabled item when orientation is vertical. | Not reviewed |
ArrowDown | Next enabled item when orientation is vertical. | Not reviewed |
Home | First enabled item. | Not reviewed |
End | Last enabled item. | Not reviewed |
Verification
Each category is reviewed separately. Automated keyboard and axe results do not attest manual or assistive-technology review.
| Category | Status | Evidence |
|---|---|---|
| Automated keyboard | Not reviewed | No declared key is mapped to a browser test yet. |
| Manual interaction | Not reviewed | No review recorded. |
| Assistive technology | Not reviewed | No review recorded. |
Examples
toolbar/basic
Horizontal action bar with roving focus among buttons.
<script setup lang="ts">
import { GhostButton, GhostToolbar } from '@ghostvue/vue'
</script>
<template>
<GhostToolbar label="Row actions" data-testid="example-toolbar-basic">
<GhostButton type="button">Edit</GhostButton>
<GhostButton type="button">Share</GhostButton>
<GhostButton type="button" disabled>Archive</GhostButton>
</GhostToolbar>
</template>
toolbar/composable
Same contract as GhostToolbar on a native host.
<script setup lang="ts">
import { useTemplateRef } from 'vue'
import { GhostButton, useGhostToolbar } from '@ghostvue/vue'
const root = useTemplateRef<HTMLElement>('root')
const { rootProps } = useGhostToolbar({
element: root,
orientation: 'horizontal',
label: 'Filters',
})
</script>
<template>
<div ref="root" v-bind="rootProps" data-testid="toolbar-composable">
<GhostButton type="button">All</GhostButton>
<GhostButton type="button">Open</GhostButton>
<GhostButton type="button">Closed</GhostButton>
</div>
</template>
toolbar/vertical
Vertical toolbar with up and down arrow movement.
<script setup lang="ts">
import { GhostButton, GhostToolbar } from '@ghostvue/vue'
</script>
<template>
<GhostToolbar orientation="vertical" label="Annotation tools">
<GhostButton type="button">Pointer</GhostButton>
<GhostButton type="button">Text</GhostButton>
<GhostButton type="button">Shape</GhostButton>
</GhostToolbar>
</template>
toolbar/separators
Group controls with semantic vertical separators.
<script setup lang="ts">
import { GhostButton, GhostSeparator, GhostToolbar } from '@ghostvue/vue'
</script>
<template>
<GhostToolbar class="clipboard" label="Clipboard">
<GhostButton type="button">Cut</GhostButton>
<GhostButton type="button">Copy</GhostButton>
<GhostButton type="button">Paste</GhostButton>
<GhostSeparator orientation="vertical" />
<GhostButton type="button">Undo</GhostButton>
<GhostButton type="button">Redo</GhostButton>
</GhostToolbar>
</template>
<style scoped>
/*
* Headless path ships no layout or visuals; this is consumer CSS for the
* sample. A row keeps the vertical separator between the button groups.
*/
.clipboard {
align-items: center;
display: flex;
flex-wrap: wrap;
gap: 0.5rem;
}
.ghost-separator {
align-self: stretch;
border-inline-start: 1px solid GrayText;
}
</style>