Skip to content
Stylhero 0.8.0
Components

Core

Layout and type

Inputs

Overlays

Navigation

Data display

Charts

Transitions and utilities

Page pieces (landing pages, portfolios, docs)

Icons

Components / Core

Switch

An on/off setting that applies immediately. Use Checkbox for choices saved with a form.

import { Switch } from "@stylhero/ui";

Example

Code
import { Switch } from "@stylhero/ui";

function SwitchExample() {
  return <Switch label="Dark mode" />;
}

Props

PropTypeDefaultDescription
label required ReactNode -

Also takes every <input> attribute (id, style, data-*, aria-*, event handlers…), passed to that element. Takes a ref.

Keyboard

KeyDoes
SpaceToggles it

Accessibility

  • A native checkbox with role="switch", announced as on / off.

Generated from src/components/Switch.tsx. Something wrong or missing? Open an issue.