apps/v4/content/docs/components/radix/switch.mdx
npx shadcn@latest add switch
<Step>Install the following dependencies:</Step>
npm install radix-ui
<Step>Copy and paste the following code into your project.</Step>
<ComponentSource name="switch" title="components/ui/switch.tsx" styleName="radix-nova" />
<Step>Update the import paths to match your project setup.</Step>
</Steps> </TabsContent> </CodeTabs>import { Switch } from "@/components/ui/switch"
<Switch />
Card-style selection where FieldLabel wraps the entire Field for a clickable card pattern.
Add the disabled prop to the Switch component to disable the switch. Add the data-disabled prop to the Field component for styling.
Add the aria-invalid prop to the Switch component to indicate an invalid state. Add the data-invalid prop to the Field component for styling.
Use the size prop to change the size of the switch.
To enable RTL support in shadcn/ui, see the RTL configuration guide.
<ComponentPreview styleName="radix-nova" name="switch-rtl" direction="rtl" />See the Radix Switch documentation.