GhostSwitch reference
Package: @ghostvue/themes. Status: experimental (stability policy).
Themed wrapper around headless GhostSwitch. Same behavioral props plus size and tone. 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 |
|---|---|---|---|---|
modelValue | boolean | — | No | Controlled on/off, forwarded to the unstyled GhostSwitch. |
defaultValue | boolean | false | No | Initial on/off when modelValue is omitted, forwarded to the unstyled GhostSwitch. |
disabled | boolean | false | No | Forwards native disabled semantics to the unstyled GhostSwitch. |
readonly | boolean | false | No | Forwards read-only semantics to the unstyled GhostSwitch. |
name | string | — | No | Form field name, forwarded to the unstyled GhostSwitch. |
value | string | "on" | No | Submitted string when on, forwarded to the unstyled GhostSwitch. |
form | string | — | No | External form id, forwarded to the unstyled GhostSwitch. |
size | 'sm' | 'md' | 'lg' | "md" | No | Control size. The default omits data-size so CSS can treat a missing hook as md. |
tone | 'accent' | 'neutral' | 'danger' | "accent" | No | Semantic color of the on track. The default omits data-tone. |
Emits
None declared.
Models
| Prop | Event | Type | Description |
|---|---|---|---|
modelValue | update:modelValue | boolean | v-model binding for on/off. |
Slots
| Name | Description |
|---|---|
default | Optional inner content, usually a visible name. Prefer a label for=id or aria-label when the name should not sit inside the control. |
Slot props: default
None declared.
Exposed members
| Name | Type | Description |
|---|---|---|
element | HTMLButtonElement | null | The native switch button after mount; null before mount and after unmount. Delegates to the unstyled GhostSwitch. |
checked | boolean | Current on/off. Delegates to the unstyled GhostSwitch. |
toggle | () => void | User-activation toggle. Delegates to the unstyled GhostSwitch. |
focus | (options?: FocusOptions) => void | Focuses the native button when it is mounted and enabled. Delegates to the unstyled GhostSwitch. |
blur | () => void | Removes focus from the native button when it is mounted. Delegates to the unstyled GhostSwitch. |
Parts and data attributes
| Attribute | Value | Description |
|---|---|---|
data-part | root | The native button element inside the display:contents themed scope. |
data-part | track | Decorative track. aria-hidden. |
data-part | thumb | Decorative thumb inside the track. aria-hidden. |
data-state | checked | On appearance. Accent, neutral, or danger fill. |
data-state | unchecked | Off appearance. Muted surface fill. |
CSS variables
| Name | Description |
|---|---|
--ghost-surface-bg | Thumb color while off, and canvas behind the control. |
--ghost-surface-muted-bg | Off-track fill. |
--ghost-surface-fg | Hover and press overlay color on the track. |
--ghost-motion-easing-standard | Easing of track color and thumb travel. |
--ghost-border-hairline-width | Forced-colors track outline thickness. |
--ghost-action-primary-bg | On-track fill for the accent tone. |
--ghost-action-primary-fg | Thumb color on the accent on-track. |
--ghost-action-neutral-bg | On-track fill for the neutral tone. |
--ghost-action-neutral-fg | Thumb color on the neutral on-track. |
--ghost-action-danger-bg | On-track fill for the danger tone. |
--ghost-action-danger-fg | Thumb color on the danger on-track. |
--ghost-action-disabled-bg | Disabled track fill. |
--ghost-action-disabled-fg | Disabled thumb color. |
--ghost-gradient-action-primary | On-track gradient for the accent tone. |
--ghost-gradient-action-neutral | On-track gradient for the neutral tone. |
--ghost-gradient-action-danger | On-track gradient for the danger tone. |
--ghost-state-layer-hover | Hover overlay opacity on the track. |
--ghost-state-layer-press | Pressed overlay opacity on the track. |
--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 track edge and the focus ring. |
--ghost-focus-ring-width | Thickness of the focus outline. |
--ghost-control-size-sm-min | Minimum hit target for size sm. The painted track is smaller. |
--ghost-control-size-sm-font | Font size the size sm track is proportioned from. |
--ghost-control-size-md-min | Minimum hit target for size md. The painted track is smaller. |
--ghost-control-size-md-font | Font size the size md track is proportioned from. |
--ghost-control-size-lg-min | Minimum hit target for size lg. The painted track is smaller. |
--ghost-control-size-lg-font | Font size the size lg track is proportioned from. |
--ghost-space-gap-sm | Gap between the track and optional slot content. |
--ghost-action-duration | Duration of track color and thumb travel. |
--ghost-action-shadow | Resting shadow on the thumb and the inner focus contrast ring. |
Accessibility
Role: switch. APG pattern: https://www.w3.org/WAI/ARIA/apg/patterns/switch/.
Required ARIA attributes: aria-checked.
Keyboard
| Key | Action | Automated browser test |
|---|---|---|
Space | Toggle the switch when it is enabled and not readonly. | Not reviewed |
Enter | Toggle the switch when it is enabled and not readonly. Implemented because the host is a native button; APG lists Enter as optional. | 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
switch/workspace-security
Policy toggles pairing GhostField labels and descriptions with GhostSwitch.
switch/themed
Visual size and tone on the @ghostvue/themes wrapper.
switch/states
Disabled switches leave the tab order; read-only ones stay.
switch/form
Named switches submit while on and restore on reset.