Components/Switch

Switch

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

Installation

npx ruma-ui add switch

Usage

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

export default function SwitchDemo() {
  return (
    <div className="flex items-center gap-3">
      <Switch id="airplane-mode" />
      <label htmlFor="airplane-mode" className="text-sm text-zinc-300">Airplane Mode</label>
    </div>
  );
}

API Reference

PropTypeDefaultDescription
checkedbooleanfalseControlled state of the switch.
onCheckedChange(checked: boolean) => voidundefinedEvent handler when toggle state changes.