Switch

Requires JS

Switches are boolean inputs that can be toggled on or off.

Usage

import { Switch } from "#/ui/components/Switch"
<Switch label="Switch" hideLabel />

Size

The switch comes in 3 different sizes

Labels

You can pass a label directly to the switch, which will automatically be associated with that switch. (be careful not to use the same label twice)

You can hide this label by passing the hideLabel prop

Or you can create your own labels anywhere in your app (note if id is used, an id will not be generated from the label)

Try toggling this switch

When used this way, you’ll need to do additional state management to make the switch work in the way you need.

Additional detail

You can optionally pass additional detail that is displayed under the label. This does not work without a label

Toggle the lights

Reverse

You can reverse the order of the label and switch by passing the reverse prop

Customisation

Classes

You can customize individual buttons by passing a className prop. If this clashes with the default styles, the className will take precedence.

Due to how tailwind-merge works, you won’t need to worry about conflicting styles when using the className prop.