Switch
A compact on/off setting with labelled, disabled and native form behavior.
Installation
npx shadcn@latest add @navui/switchUsage
Use a switch for an on/off setting and keep its label stable across states. Install NavUI Field to connect visible labels and descriptions.
import { Switch } from "@/components/navui/switch";
import { Field, FieldLabel } from "@/components/navui/field";
export function EmailNotifications() {
return (
<Field name="notifications" className="min-h-8 flex-row items-center gap-3 pointer-coarse:min-h-11">
<FieldLabel>Email notifications</FieldLabel>
<Switch value="enabled" />
</Field>
);
}Examples
Default
With a description
Get a summary of workspace activity every Monday.
Disabled
Managed by your organization
Controlled setting
Teammates can see when you’re active.
Workspace preferences
Saving a preference
The first attempt simulates a connection error. Toggle again to retry.
Back up project settings once a day.
API reference
Foundation component styled on UI SDK Switch. See the UI SDK Switch documentation for the complete inherited API.
Accessibility
- Use a visible label that describes the setting in both states.