Skip to content

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.

All component references

Props ​

NameTypeDefaultRequiredDescription
modelValueboolean—NoControlled on/off, forwarded to the unstyled GhostSwitch.
defaultValuebooleanfalseNoInitial on/off when modelValue is omitted, forwarded to the unstyled GhostSwitch.
disabledbooleanfalseNoForwards native disabled semantics to the unstyled GhostSwitch.
readonlybooleanfalseNoForwards read-only semantics to the unstyled GhostSwitch.
namestring—NoForm field name, forwarded to the unstyled GhostSwitch.
valuestring"on"NoSubmitted string when on, forwarded to the unstyled GhostSwitch.
formstring—NoExternal form id, forwarded to the unstyled GhostSwitch.
size'sm' | 'md' | 'lg'"md"NoControl size. The default omits data-size so CSS can treat a missing hook as md.
tone'accent' | 'neutral' | 'danger'"accent"NoSemantic color of the on track. The default omits data-tone.

Emits ​

None declared.

Models ​

PropEventTypeDescription
modelValueupdate:modelValuebooleanv-model binding for on/off.

Slots ​

NameDescription
defaultOptional 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 ​

NameTypeDescription
elementHTMLButtonElement | nullThe native switch button after mount; null before mount and after unmount. Delegates to the unstyled GhostSwitch.
checkedbooleanCurrent on/off. Delegates to the unstyled GhostSwitch.
toggle() => voidUser-activation toggle. Delegates to the unstyled GhostSwitch.
focus(options?: FocusOptions) => voidFocuses the native button when it is mounted and enabled. Delegates to the unstyled GhostSwitch.
blur() => voidRemoves focus from the native button when it is mounted. Delegates to the unstyled GhostSwitch.

Parts and data attributes ​

AttributeValueDescription
data-partrootThe native button element inside the display:contents themed scope.
data-parttrackDecorative track. aria-hidden.
data-partthumbDecorative thumb inside the track. aria-hidden.
data-statecheckedOn appearance. Accent, neutral, or danger fill.
data-stateuncheckedOff appearance. Muted surface fill.

CSS variables ​

NameDescription
--ghost-surface-bgThumb color while off, and canvas behind the control.
--ghost-surface-muted-bgOff-track fill.
--ghost-surface-fgHover and press overlay color on the track.
--ghost-motion-easing-standardEasing of track color and thumb travel.
--ghost-border-hairline-widthForced-colors track outline thickness.
--ghost-action-primary-bgOn-track fill for the accent tone.
--ghost-action-primary-fgThumb color on the accent on-track.
--ghost-action-neutral-bgOn-track fill for the neutral tone.
--ghost-action-neutral-fgThumb color on the neutral on-track.
--ghost-action-danger-bgOn-track fill for the danger tone.
--ghost-action-danger-fgThumb color on the danger on-track.
--ghost-action-disabled-bgDisabled track fill.
--ghost-action-disabled-fgDisabled thumb color.
--ghost-gradient-action-primaryOn-track gradient for the accent tone.
--ghost-gradient-action-neutralOn-track gradient for the neutral tone.
--ghost-gradient-action-dangerOn-track gradient for the danger tone.
--ghost-state-layer-hoverHover overlay opacity on the track.
--ghost-state-layer-pressPressed overlay opacity on the track.
--ghost-focus-ring-colorOuter color of the two-color keyboard focus indicator.
--ghost-focus-ring-contrastInner color of the two-color keyboard focus indicator.
--ghost-focus-ring-offsetGap between the track edge and the focus ring.
--ghost-focus-ring-widthThickness of the focus outline.
--ghost-control-size-sm-minMinimum hit target for size sm. The painted track is smaller.
--ghost-control-size-sm-fontFont size the size sm track is proportioned from.
--ghost-control-size-md-minMinimum hit target for size md. The painted track is smaller.
--ghost-control-size-md-fontFont size the size md track is proportioned from.
--ghost-control-size-lg-minMinimum hit target for size lg. The painted track is smaller.
--ghost-control-size-lg-fontFont size the size lg track is proportioned from.
--ghost-space-gap-smGap between the track and optional slot content.
--ghost-action-durationDuration of track color and thumb travel.
--ghost-action-shadowResting 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 ​

KeyActionAutomated browser test
SpaceToggle the switch when it is enabled and not readonly.Not reviewed
EnterToggle 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.

CategoryStatusEvidence
Automated keyboardNot reviewedNo declared key is mapped to a browser test yet.
Manual interactionNot reviewedNo review recorded.
Assistive technologyNot reviewedNo review recorded.

Examples ​

switch/workspace-security ​

Example source

Workspace security

Policy toggles pairing GhostField labels and descriptions with GhostSwitch.

Workspace security

Control authentication and sharing policies across all projects.

switch/themed ​

Example source

Themed

Visual size and tone on the @ghostvue/themes wrapper.

switch/states ​

Example source

Disabled and read-only

Disabled switches leave the tab order; read-only ones stay.

switch/form ​

Example source

Form value

Named switches submit while on and restore on reset.