Switch
A control that allows the user to toggle between checked and not checked.
import { Switch } from "stylus-ui/Switch";
export default () => <Switch />;Pass text or an element to label to display beside the switch. By default, the switch row will grow to accommodate the width of the parent container.
import { Switch } from "stylus-ui/Switch";
export default () => ( <form className="flex w-72 flex-col gap-3"> <Switch label="Override organization permissions" /> <Switch label="Enable documents export" /> </form>);Help text
Section titled “Help text”Pass text or an element to label to display beside the switch. By default, the switch row will grow to accommodate the width of the parent container.
import { Switch } from "stylus-ui/Switch";
export default () => ( <form className="w-72"> <Switch label="Scribe views" helpText="Enable notifications for when others view your Scribe" /> </form>);Disabled
Section titled “Disabled”Set disabled to prevent interaction with the switch.
import { Switch } from "stylus-ui/Switch";
export default () => ( <form className="w-72"> <Switch label="Scribe views" helpText="Enable notifications for when others view your Scribe" disabled /> </form>);Controlled
Section titled “Controlled”To control the state, use checked and onCheckedChange.
import { useState } from "react";import { Switch } from "stylus-ui/Switch";
export default () => { const [isEnabled, setIsEnabled] = useState(false);
return ( <form className="w-72"> <Switch label="Scribe views" helpText="Enable notifications for when others view your Scribe" checked={isEnabled} onCheckedChange={setIsEnabled} /> </form> );};API Reference
Section titled “API Reference”Switch
Section titled “Switch”A control that allows the user to toggle between checked and not checked.
asChild
boolean
checked
boolean
defaultChecked
boolean
helpText
string
Helper text shown below the switch.
label
ReactNode
Label shown beside the switch (visually on the left).
onCheckedChange
(checked: boolean) => void
required
boolean
theme
"light" | "dark" = "light"
Visual theme for the switch track and label.