GhostButton reference
Package: @ghostvue/vue. Status: experimental (stability policy).
Headless native action control. useGhostButton owns behavior; GhostButton is the thin unstyled element. Themed visual props live on @ghostvue/themes.
Generated from the component manifest. Edit the manifest or Vue source, then rebuild the docs.
Props
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
disabled | boolean | false | No | Applies native disabled semantics, prevents activation, and removes the button from sequential focus order. |
loading | boolean | false | No | Consumer-owned pending state. Prevents activation while remaining focusable, sets aria-disabled and aria-busy, and preserves slot content so the accessible name does not change. |
type | GhostButtonType | "button" | No | Native button behavior. Defaults to button so a control inside a form does not submit unless the consumer opts in. |
Emits
None declared.
Models
None declared.
Slots
| Name | Description |
|---|---|
default | Button label and optional decorative content such as an icon. Icon-only use requires aria-label, aria-labelledby, or hidden text. |
Slot props: default
None declared.
Exposed members
| Name | Type | Description |
|---|---|---|
blur | () => void | Removes focus from the native button when it is mounted. No-op before mount. |
element | HTMLButtonElement | null | The native button after mount; null before mount and after unmount. |
focus | (options?: FocusOptions) => void | Focuses the native button when it is mounted and enabled. No-op before mount. |
Parts and data attributes
| Attribute | Value | Description |
|---|---|---|
data-part | root | The native button element. |
data-part | icon | Optional decorative icon content inside the default slot. |
data-part | loading-indicator | Optional decorative pending indicator inside the default slot. Replaces the themed default spinner when present. |
data-state | loading | Pending action. Used when native disabled is the wrong focus model. Wins over disabled when both props are true. |
data-state | disabled | Unavailable action. Prefer the native disabled attribute when both apply. Omitted while loading. |
CSS variables
None declared.
Accessibility
Role: button. APG pattern: https://www.w3.org/WAI/ARIA/apg/patterns/button/.
Required ARIA attributes: none.
Keyboard
| Key | Action | Automated browser test |
|---|---|---|
Enter | Activate the button when it is enabled and not loading. | Not reviewed |
Space | Activate the button when it is enabled and not loading. | 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
button/basic
Basic Headless
Native action control. The default type is button.
basic.vue
vue
<script setup lang="ts">
import { ref } from 'vue'
import { GhostButton } from '@ghostvue/vue'
const saved = ref(false)
function save(): void {
saved.value = true
}
</script>
<template>
<GhostButton @click="save">Save changes</GhostButton>
</template>
button/composable
Composable Headless
Same contract as GhostButton, applied to a native host.
composable.vue
vue
<script setup lang="ts">
import { onBeforeUnmount, ref } from 'vue'
import { useGhostButton } from '@ghostvue/vue'
const saving = ref(false)
const { rootProps } = useGhostButton({ loading: saving })
let resetTimer: ReturnType<typeof setTimeout> | undefined
function save(): void {
saving.value = true
resetTimer = setTimeout(() => {
saving.value = false
}, 1200)
}
onBeforeUnmount(() => {
clearTimeout(resetTimer)
})
</script>
<template>
<button v-bind="rootProps" @click="save">Save</button>
</template>
button/ref
Component ref Headless
Template refs expose element, focus, and blur.
ref.vue
vue
<script setup lang="ts">
import { useTemplateRef } from 'vue'
import { GhostButton, type GhostButtonExposed } from '@ghostvue/vue'
const saveButton = useTemplateRef<GhostButtonExposed>('saveButton')
function returnFocus(): void {
saveButton.value?.focus()
}
</script>
<template>
<GhostButton ref="saveButton">Save changes</GhostButton>
<button type="button" @click="returnFocus">Move focus to save</button>
</template>