sheengemologic ui
All components

Switch

A labeled binary setting with native form participation and switch semantics.@gemologic/sheen · forms

Playground

Refresh this view automatically.

<Switch label="Live updates" defaultChecked description="Refresh this view automatically." />

Variant matrix

Live updates

Refresh this view automatically.

Anatomy

Package
@gemologic/sheen
Source
packages/ui/src/primitives/Switch.tsx
Tokens
  • --sheen-color-accent
  • --sheen-color-border-control
  • --sheen-color-focus-ring
  • --sheen-icon-size-md

Accessibility

Role: switchKeyboard: Tab, Shift+Tab, Space

Do

  • Use a stable label describing the setting, not its current value.

Do not

  • Do not use mixed state; a switch is strictly on or off.

Generated props

NameTypeDefaultDescription
descriptionstringAssociated supporting instructions.
idstringRoot container ID used to derive internal IDs.
refHTMLDivElement | ((element: HTMLDivElement) => void) | undefinedRoot container reference; inputRef targets the native input.
onPointerDownNonNullable<JSX.EventHandlerUnion<HTMLDivElement, PointerEvent, JSX.EventHandler<HTMLDivElement, PointerEvent>> | undefined> | undefinedNative root pointer-down handler composed with focus behavior.
label *stringRequired visible label, unchanged between on and off.
errorstringAssociated error marking the control invalid without moving focus.
checkedbooleanApp-owned state, retained on reset unless the app changes it.
defaultCheckedbooleanfalseInitial uncontrolled state restored on uncanceled reset.
onCheckedChange((checked: boolean) => void) | undefinedReceives the requested boolean state, not a DOM event.
disabledbooleanfalsePrevents changes, keyboard focus, and form submission.
readOnlybooleanfalsePrevents changes while retaining focus and submission.
requiredbooleanfalseRequires the switch to be on for native form validation.
namestringNative form name; empty or omitted names are not submitted.
formstring | undefinedExternal owning form ID, forwarded to the native input.
valuestringonValue submitted when on.
inputRef((element: HTMLInputElement) => void) | undefinedReceives the native input.
Native Solid/HTML attributes remain available and are omitted from this authored-prop view.