docs/components/input/Switch

Switch

On/off toggle switch.

import { Switch } from '@ybouhjira/hyperkit';

#Playground

Edit the code — the preview recompiles and re-renders as you type.

Live playground
Loading preview…

#More Examples

With Description

<Switch
  label="Marketing emails"
  description="Receive emails about new products and features"
/>

Small

<Switch label="Small switch" size="sm" />

#Props

PropTypeDefaultDescription
checkedbooleanControlled checked state.
defaultCheckedbooleanfalseInitial checked state for uncontrolled mode.
onChange(checked: boolean) => voidCallback when checked state changes.
disabledbooleanfalseDisable the switch.
labelstringLabel text displayed next to the switch.
descriptionstringDescription text displayed below the label.
size'sm' | 'md''md'Size preset.
classstringAdditional CSS classes.
unstyledbooleanfalseRemove all default styling classes.

#Design Tokens

This component reads the following CSS custom properties. Override them globally or per-instance to restyle it — see the CSS Variables guide.

  • --sk-accent
  • --sk-bg-tertiary
  • --sk-duration-fast
  • --sk-font-size-sm
  • --sk-font-size-xs
  • --sk-font-weight-medium
  • --sk-space-sm
  • --sk-switch-thumb-bg
  • --sk-switch-track-bg
  • --sk-switch-track-bg-checked
  • --sk-text-muted
  • --sk-text-primary