Murasaki

Switch

A control that allows the user to toggle between checked and not checked.

import { Label, Switch } from "@murasakijs/ui";export function SwitchDemo() {return (  <div className="flex items-center gap-2">    <Switch id="airplane-mode" />    <Label htmlFor="airplane-mode">Airplane Mode</Label>  </div>);}

Usage

import { Switch } from "@murasakijs/ui";
<Switch id="airplane-mode" />

API Reference

Props

PropTypeDefault
checkedboolean
defaultCheckedboolean
onCheckedChange(checked: boolean) => void
disabledbooleanfalse
requiredbooleanfalse
namestring
valuestring"on"

Switch renders a Radix UI Switch.Root; all other props are forwarded to it.

Improve this page on GitHub

On this page