GhostButton reference
Package: @ghostvue/themes. Status: experimental (stability policy).
Themed wrapper around headless GhostButton. Same behavioral props plus variant, tone, size, block, and iconOnly. Importing it loads the default stylesheet and scopes styles to this instance. Hand-written until GHO-13 generates manifests.
Generated from the component manifest. Edit the manifest or Vue source, then rebuild the docs.
Props
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
type | 'button' | 'submit' | 'reset' | "button" | No | Native button behavior, forwarded to the unstyled GhostButton. |
disabled | boolean | false | No | Forwards native disabled semantics to the unstyled GhostButton. |
loading | boolean | false | No | Forwards consumer-owned pending state to the unstyled GhostButton. |
variant | 'solid' | 'soft' | 'outline' | 'ghost' | "solid" | No | Visual treatment. The default omits data-variant so CSS can treat a missing hook as solid. |
tone | 'accent' | 'neutral' | 'danger' | "accent" | No | Semantic color intent, independent of variant. The default omits data-tone. |
size | 'sm' | 'md' | 'lg' | "md" | No | Control size. The default omits data-size so CSS can treat a missing hook as md. |
block | boolean | false | No | Stretch to the available inline size via data-block. |
iconOnly | boolean | false | No | Square icon-button treatment via data-icon-only. Still requires an accessible name. |
interactive | 'spotlight' | — | No | Opt-in pointer spotlight. Off by default. Sets data-interactive and tracks on data-interactive-state so loading/disabled keep data-state. |
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 |
|---|---|---|
element | HTMLButtonElement | null | The native button after mount; null before mount and after unmount. Delegates to the unstyled GhostButton. |
focus | (options?: FocusOptions) => void | Focuses the native button when it is mounted and enabled. Delegates to the unstyled GhostButton. |
blur | () => void | Removes focus from the native button when it is mounted. Delegates to the unstyled GhostButton. |
Parts and data attributes
| Attribute | Value | Description |
|---|---|---|
data-part | root | The native button element inside the display:contents themed scope. |
data-part | icon | Optional decorative icon content inside the default slot. |
data-part | loading-indicator | Optional decorative pending indicator. Replaces the default spinner when present. |
data-part | glow | Decorative spotlight overlay rendered when interactive is spotlight. aria-hidden. |
data-state | loading | Pending action. Overlay spinner and wait cursor. Wins over disabled for data-state. |
data-state | disabled | Unavailable appearance. Prefer the native disabled attribute when both apply. |
data-variant | soft, outline, ghost | Visual treatment on the root button. Absent for the default solid variant. |
data-tone | neutral, danger | Semantic color intent on the root button. Absent for the default accent tone. |
data-size | sm, lg | Control size on the root button. Absent for the default md size. |
data-block | present | Present on the root button when block is true. |
data-icon-only | present | Present on the root button when iconOnly is true. |
data-interactive | spotlight | Present on the root button when interactive is spotlight. |
data-interactive-state | off, idle, tracking | Spotlight pointer state on the root button: off while reduced motion or a coarse pointer disables the effect, idle while opted in and at rest, tracking while the pointer is over the button. Kept separate from data-state so loading and disabled stay stylable. |
CSS variables
| Name | Description |
|---|---|
--ghost-surface-bg | Canvas background on .ghost-theme and the mix surface for soft, outline, and ghost treatments. |
--ghost-surface-fg | Canvas foreground on .ghost-theme. |
--ghost-action-primary-bg | Solid background fallback and outline/ghost foreground for the accent tone. |
--ghost-action-primary-fg | Content color on the solid accent treatment. |
--ghost-action-primary-border | Border color on the solid accent treatment. |
--ghost-action-primary-gradient-from | Accent solid gradient start. Contrast-gated against accent foreground. |
--ghost-action-primary-gradient-to | Accent solid gradient end. Contrast-gated against accent foreground. |
--ghost-action-neutral-bg | Solid background fallback and outline/ghost foreground for the neutral tone. |
--ghost-action-neutral-fg | Content color on the solid neutral treatment. |
--ghost-action-neutral-border | Border color on the solid neutral treatment. |
--ghost-action-danger-bg | Solid background fallback and outline/ghost foreground for the danger tone. |
--ghost-action-danger-fg | Content color on the solid danger treatment. |
--ghost-action-danger-border | Border color on the solid danger treatment. |
--ghost-action-disabled-bg | Desaturated unavailable background. Used instead of fading the rest tone. |
--ghost-action-disabled-fg | Unavailable foreground. Reduced emphasis, still legible. |
--ghost-action-disabled-border | Unavailable border. |
--ghost-action-disabled-opacity | Shared unavailable-state opacity. GhostButton uses dedicated disabled colors instead. |
--ghost-gradient-action-primary | Oklch gradient fill for solid accent actions. |
--ghost-gradient-action-neutral | Oklch gradient fill for solid neutral actions. |
--ghost-gradient-action-danger | Oklch gradient fill for solid danger actions. |
--ghost-state-layer-hover | Hover overlay opacity on the current tone. |
--ghost-state-layer-press | Pressed overlay opacity on the current tone. |
--ghost-state-layer-selected | Selected overlay opacity, used when aria-pressed is true. |
--ghost-state-layer-dragged | Dragged overlay opacity, used when aria-grabbed is true. |
--ghost-motion-press-scale | Pressed scale. 1 under reduced motion. |
--ghost-focus-ring-duration | Focus-ring entrance duration. Instant under reduced motion. |
--ghost-action-duration | Duration of color and opacity transitions. |
--ghost-action-gap | Space between label and icon content. |
--ghost-action-icon-size | Size of content marked data-part=icon. |
--ghost-action-label-weight | Button label font weight. |
--ghost-action-radius | Corner radius of the themed button. |
--ghost-action-spinner-size | Size of the default and custom loading indicators. |
--ghost-action-spinner-width | Stroke width of the default loading spinner. |
--ghost-focus-ring-color | Outer color of the two-color keyboard focus indicator. |
--ghost-focus-ring-contrast | Inner color of the two-color keyboard focus indicator. |
--ghost-focus-ring-offset | Gap between the button edge and the focus ring. |
--ghost-focus-ring-width | Thickness of the focus outline. |
--ghost-control-size-sm-min | Minimum block size for size sm. |
--ghost-control-size-sm-padding-block | Block padding for size sm. |
--ghost-control-size-sm-padding-inline | Inline padding for size sm. |
--ghost-control-size-md-min | Minimum block size for size md. |
--ghost-control-size-md-padding-block | Block padding for size md. |
--ghost-control-size-md-padding-inline | Inline padding for size md. |
--ghost-control-size-lg-min | Minimum block size for size lg. |
--ghost-control-size-lg-padding-block | Block padding for size lg. |
--ghost-control-size-lg-padding-inline | Inline padding for size lg. |
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/action-bar
Primary, secondary, and destructive actions with a pending publish.
Overrides: none, showing the original example
Original source. Playground overrides are not applied here; use Copy props for the current settings.
<script setup lang="ts">
import { onBeforeUnmount, ref } from 'vue'
import { GhostButton, type GhostButtonSize } from '@ghostvue/themes'
/*
* Optional so the sample runs as-is; the docs props playground passes them.
* `size` applies to every action so the row keeps one rhythm. `loading`
* shows the publish action as pending, the same state a click produces.
*/
const { size = 'md', loading } = defineProps<{
size?: GhostButtonSize
loading?: boolean
}>()
const publishing = ref(false)
const status = ref('Draft saved at 10:42')
let publishTimer: ReturnType<typeof setTimeout> | undefined
function saveDraft(): void {
status.value = 'Draft saved at 10:43'
}
function discardDraft(): void {
status.value = 'Changes discarded'
}
// Stands in for a request. The app owns the pending state and the result.
function publish(): void {
publishing.value = true
status.value = 'Publishing to 3 channels…'
publishTimer = setTimeout(() => {
publishing.value = false
status.value = 'Published to 3 channels'
}, 1500)
}
onBeforeUnmount(() => {
clearTimeout(publishTimer)
})
</script>
<template>
<div class="publish-bar">
<div class="publish-bar__summary">
<span class="publish-bar__title">Quarterly product update</span>
<!-- Announces save, discard, and publish results politely. -->
<span class="publish-bar__status" role="status">{{ status }}</span>
</div>
<div class="publish-bar__actions">
<div class="publish-bar__discard">
<GhostButton variant="ghost" tone="danger" :size @click="discardDraft">
Discard changes
</GhostButton>
</div>
<div class="publish-bar__commit">
<GhostButton variant="outline" tone="neutral" :size @click="saveDraft">
Save draft
</GhostButton>
<GhostButton :size :loading="loading || publishing" @click="publish">
Publish
</GhostButton>
</div>
</div>
</div>
</template>
<style scoped>
/*
* The summary sits above the actions. The destructive action lives in its
* own group at the start so it is never the button next to the primary.
* Narrow previews stack the groups and give Save and Publish equal halves;
* wider ones put the groups on one row at opposite ends.
*/
.publish-bar {
display: grid;
gap: var(--ghost-space-stack-md);
}
.publish-bar__summary {
display: grid;
gap: var(--ghost-space-gap-xs);
min-inline-size: 0;
}
.publish-bar__title {
color: var(--ghost-text-default);
font-size: var(--ghost-type-size-md);
font-weight: var(--ghost-type-weight-semibold);
line-height: var(--ghost-type-line-snug);
}
.publish-bar__status {
color: var(--ghost-text-muted);
font-size: var(--ghost-type-size-sm);
line-height: var(--ghost-type-line-normal);
}
.publish-bar__actions {
display: grid;
gap: var(--ghost-space-gap-sm);
}
/* Save and Publish split the row evenly on narrow previews. */
.publish-bar__commit {
display: grid;
gap: var(--ghost-space-gap-sm);
grid-template-columns: 1fr 1fr;
}
@container ghost-demo (min-width: 26rem) {
.publish-bar__actions {
align-items: center;
display: flex;
flex-wrap: wrap;
justify-content: space-between;
}
.publish-bar__commit {
display: flex;
flex-wrap: wrap;
}
}
</style>
button/refresh-status
A keyboard-triggered refresh keeps focus while pending and after a failure, then succeeds on retry.
<script setup lang="ts">
import { onBeforeUnmount, ref } from 'vue'
import { GhostButton } from '@ghostvue/themes'
type RefreshResult = 'idle' | 'pending' | 'failed' | 'updated'
const result = ref<RefreshResult>('idle')
const attempts = ref(0)
let requestTimer: ReturnType<typeof setTimeout> | undefined
const messages: Record<RefreshResult, string> = {
idle: 'Last checked 5 minutes ago.',
pending: 'Checking 3 deployments…',
failed: 'Could not reach the build server. Try again.',
updated: 'All 3 deployments are healthy.',
}
/*
* The application owns the request. `loading` only blocks activation while
* it runs: the button stays focused and keeps its name, so a keyboard user
* can retry from where they are once the failure clears the pending state.
* The first attempt fails so the example shows that recovery path.
*/
function refresh(): void {
attempts.value += 1
const fails = attempts.value === 1
result.value = 'pending'
requestTimer = setTimeout(() => {
result.value = fails ? 'failed' : 'updated'
}, 900)
}
onBeforeUnmount(() => {
clearTimeout(requestTimer)
})
</script>
<template>
<div class="refresh-status">
<div class="refresh-status__summary">
<span class="refresh-status__title">Production deployments</span>
<!-- A polite region announces each outcome without moving focus. -->
<span class="refresh-status__message" :data-result="result" role="status">
{{ messages[result] }}
</span>
</div>
<GhostButton
variant="outline"
tone="neutral"
:loading="result === 'pending'"
@click="refresh"
>
Refresh status
</GhostButton>
</div>
</template>
<style scoped>
.refresh-status {
display: grid;
gap: var(--ghost-space-gap-sm);
justify-items: start;
}
.refresh-status__summary {
display: grid;
gap: var(--ghost-space-gap-xs);
min-inline-size: 0;
}
.refresh-status__title {
color: var(--ghost-text-default);
font-size: var(--ghost-type-size-md);
font-weight: var(--ghost-type-weight-semibold);
line-height: var(--ghost-type-line-snug);
}
.refresh-status__message {
color: var(--ghost-text-muted);
font-size: var(--ghost-type-size-sm);
line-height: var(--ghost-type-line-normal);
}
.refresh-status__message[data-result='failed'] {
color: var(--ghost-text-danger);
}
@container ghost-demo (min-width: 30rem) {
.refresh-status {
align-items: center;
grid-template-columns: minmax(0, 1fr) auto;
}
}
</style>
button/configured
Typed visual props and a loading state the application owns.
<script setup lang="ts">
import { onBeforeUnmount, ref } from 'vue'
import { GhostButton } from '@ghostvue/themes'
const saving = ref(false)
let resetTimer: ReturnType<typeof setTimeout> | undefined
function save(): void {
saving.value = true
resetTimer = setTimeout(() => {
saving.value = false
}, 1200)
}
onBeforeUnmount(() => {
clearTimeout(resetTimer)
})
</script>
<template>
<!--
Visual props describe intent. `type` defaults to button so this control
does not submit a surrounding form. Loading keeps the control focusable
while the pending request runs.
-->
<GhostButton
variant="solid"
tone="accent"
size="md"
:loading="saving"
@click="save"
>
Save changes
</GhostButton>
</template>
button/themed
Visual props on the @ghostvue/themes wrapper.
Overrides: none, showing the original example
Original source. Playground overrides are not applied here; use Copy props for the current settings.
<script setup lang="ts">
import { ref } from 'vue'
import {
GhostButton,
type GhostButtonSize,
type GhostButtonTone,
type GhostButtonVariant,
} from '@ghostvue/themes'
/*
* Optional so the sample runs as-is; the docs props playground passes them
* to try other treatments. The defaults are what this sample renders.
*/
const {
size = 'md',
tone = 'danger',
variant = 'outline',
} = defineProps<{
size?: GhostButtonSize
tone?: GhostButtonTone
variant?: GhostButtonVariant
}>()
const saving = ref(false)
</script>
<template>
<GhostButton :variant :tone :size :loading="saving">Delete</GhostButton>
</template>
button/loading
Pending actions keep their width and focus; disabled ones do not.
<script setup lang="ts">
import { GhostButton } from '@ghostvue/themes'
</script>
<template>
<!--
Loading keeps the label in the layout (only hidden), so the button keeps
its width and the row does not shift when an action becomes pending.
-->
<div class="button-states">
<GhostButton loading>Save changes</GhostButton>
<GhostButton variant="outline" tone="neutral" loading>
Export report
</GhostButton>
<GhostButton disabled>Unavailable action</GhostButton>
</div>
</template>
<style scoped>
.button-states {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: var(--ghost-space-gap-sm);
}
</style>
button/marked-parts
Icons and a custom loading indicator using data-part in the default slot.
<script setup lang="ts">
import { onBeforeUnmount, ref } from 'vue'
import { GhostButton } from '@ghostvue/themes'
const saving = ref(false)
let resetTimer: ReturnType<typeof setTimeout> | undefined
function save(): void {
saving.value = true
resetTimer = setTimeout(() => {
saving.value = false
}, 1200)
}
onBeforeUnmount(() => {
clearTimeout(resetTimer)
})
</script>
<template>
<GhostButton class="marked-save" :loading="saving" @click="save">
<svg
data-part="icon"
aria-hidden="true"
viewBox="0 0 16 16"
width="16"
height="16"
>
<path
d="M3 13.5V6.2L8 2.5l5 3.7v7.3H3zm2-1h6V7.1L8 4.2 5 7.1v5.4z"
fill="currentColor"
/>
</svg>
<span>Save changes</span>
<span v-if="saving" data-part="loading-indicator" aria-hidden="true">
…
</span>
</GhostButton>
</template>
<style scoped>
/*
* data-part marks slot structure the themed wrapper understands.
* Consumer CSS targets parts without coupling to the library DOM.
*/
.marked-save :deep([data-part='icon']) {
display: inline-flex;
}
.marked-save :deep([data-part='loading-indicator']) {
font-size: 0.875em;
letter-spacing: 0.12em;
opacity: 0.85;
}
</style>
button/icon-only
Square treatment with an accessible name from aria-label.
<script setup lang="ts">
import { GhostButton } from '@ghostvue/themes'
</script>
<template>
<GhostButton icon-only aria-label="Close dialog">
<svg
data-part="icon"
aria-hidden="true"
viewBox="0 0 16 16"
width="16"
height="16"
>
<path
d="M3 3l10 10M13 3L3 13"
fill="none"
stroke="currentColor"
stroke-width="1.5"
/>
</svg>
</GhostButton>
</template>