CraftUI

Switch

The Ore UI toggle, a sliding block over a track marked I when on and O when off.

Installation

npx shadcn@latest add @runqora/craft-switch

Usage

import { Switch } from "@/components/craft/switch";

<Switch label="Show coordinates" />;

Examples

Controlled

Music is on.

Props

Prop

Type

Accessibility

  • Has the switch role, and Space toggles it.
  • label is joined to the switch, so clicking the text works too. Without a label, pass aria-label.
  • The I and O marks show the state as well as the color.

Customization

The size of the switch follows --craft-unit, so a larger unit makes a larger switch with the same proportions.

<Switch className="[--craft-unit:3px]" label="Big switch" />

Dependencies

Source

On this page