Skip to content

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>
);

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.

Enable notifications for when others view your Scribe

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>
);

Set disabled to prevent interaction with the switch.

Enable notifications for when others view your Scribe

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>
);

Inherits properties from HTMLButtonElement.

Prop
Type
Default
asChild boolean false
checked boolean
className string
defaultChecked boolean
disabled boolean
helpText string
label ReactNode
name string
onCheckedChange (checked: boolean) => void
required boolean
theme "light""dark" "light"
value string "on"