HextaUI

Switch: On and off marks

icons adds a check and a ring to the track, so the state doesn't rely on color.

import { Switch } from "@/components/ui/switch"

export function SwitchIcons() {
  return (
    <div className="flex flex-col gap-4 text-sm">
      <label className="flex items-center gap-3">
        <Switch icons defaultChecked />
        Captions
      </label>
      <label className="flex items-center gap-3">
        <Switch icons size="lg" />
        Reduce transparency
      </label>
    </div>
  )
}

This adds the example as components/examples/switch/icons.tsx, together with the Switch component and the HextaUI theme tokens it needs.

pnpm dlx shadcn@latest add https://hextaui.com/r/switch-icons.json

To add only the component, follow the Switch installation.

Props in this example

The Switch props this example sets, from the API reference.

PropTypeDefault
defaultChecked
booleanfalse
size
"sm" | "default" | "lg""default"
iconsShow on and off marks in the track.
booleanfalse

Every prop is in the Switch API reference.

See them all, with keyboard support and accessibility notes, on the Switch page.