--- title: Switch description: A control that indicates whether a setting is on or off. links: doc: https://base-ui.com/react/components/switch#api-reference --- ## Preview ## Installation CLI Manual ```bash npx @olyx/cli@latest add switch ``` Install the following dependencies: ```bash npm install @base-ui/react ``` Copy and paste the following code into your project. Update the import paths to match your project setup. ## Usage ```tsx import { Switch } from "@/components/ui/switch" ``` ```tsx ``` ## API Reference ### Switch Styled wrapper for `Switch.Root` from Base UI with built-in thumb. Size is controlled via the `--track-size` CSS variable. ## Examples For accessible labelling and validation, prefer using the `Field` component to wrap checkboxes. See the related example: [Switch field](/ui/docs/components/field#switch-field). ### Disabled ### With Description ### Customizing Size The switch size is controlled by the `--track-size` CSS variable. By default, the switch uses `36px`. You can customize the size by overriding this CSS variable on the component using inline styles or a custom class. ### Card Style ### Form Integration