📄 radixui/themes/docs/components/switch

File: switch.md | Updated: 11/15/2025

Source: https://www.radix-ui.com/themes/docs/components/switch

Radix Homepage

Made by WorkOS

Radix Homepage

Made by WorkOS

ThemesThemes PrimitivesPrimitives IconsIcons ColorsColors

Documentation Playground Blog

Overview

Getting started Styling Layout Releases Resources

Theme

Overview Color Dark mode Typography Spacing Breakpoints Radius Shadows Cursors

Layout

Box Flex Grid Container Section

Typography

Text Heading Blockquote Code Em Kbd Link Quote Strong

Components

Alert Dialog Aspect Ratio Avatar Badge Button Callout Card Checkbox Checkbox Group Checkbox Cards Context Menu Data List Dialog Dropdown Menu Hover Card Icon Button Inset Popover Progress Radio Radio Group Radio Cards Scroll Area Segmented Control Select Separator Skeleton Slider Spinner Switch Table Tabs Tab Nav Text Area Text Field Tooltip

Utilities

Accessible Icon Portal Reset Slot Theme Visually Hidden

Components

Switch

Toggle switch alternative to the checkbox.

View source Report an issue View in Playground

<Switch defaultChecked />

API Reference


This component inherits props from the Switch primitive and supports common margin props .

| Prop | Type | Default | | --- | --- | --- | | size | Responsive<"1" \| "2" \| "3"> | "2" | | variant<br><br>Prop description | "classic" \| "surface" \| "soft" | "surface" | | color<br><br>Prop description | enum<br><br>See full type | No default value | | highContrast<br><br>Prop description | boolean | No default value | | radius<br><br>Prop description | "none" \| "small" \| "medium" \| "large" \| "full" | No default value |

Examples


Size

Use the size prop to control the size of the switch.

<Flex align="center" gap="2">
	<Switch size="1" defaultChecked />
	<Switch size="2" defaultChecked />
	<Switch size="3" defaultChecked />
</Flex>

Variant

Use the variant prop to control the visual style of the switch.

<Flex gap="2">
	<Flex direction="column" gap="3">
		<Switch variant="surface" />
		<Switch variant="classic" />
		<Switch variant="soft" />
	</Flex>

	<Flex direction="column" gap="3">
		<Switch variant="surface" defaultChecked />
		<Switch variant="classic" defaultChecked />
		<Switch variant="soft" defaultChecked />
	</Flex>
</Flex>

Color

Use the color prop to assign a specific color .

<Flex gap="2">
	<Switch color="indigo" defaultChecked />
	<Switch color="cyan" defaultChecked />
	<Switch color="orange" defaultChecked />
	<Switch color="crimson" defaultChecked />
</Flex>

High-contrast

Use the highContrast prop to increase color contrast in light mode.

<Grid rows="2" gapX="2" gapY="3" display="inline-grid" flow="column">
	<Switch color="indigo" defaultChecked />
	<Switch color="indigo" defaultChecked highContrast />
	<Switch color="cyan" defaultChecked />
	<Switch color="cyan" defaultChecked highContrast />
	<Switch color="orange" defaultChecked />
	<Switch color="orange" defaultChecked highContrast />
	<Switch color="crimson" defaultChecked />
	<Switch color="crimson" defaultChecked highContrast />
	<Switch color="gray" defaultChecked />
	<Switch color="gray" defaultChecked highContrast />
</Grid>

Radius

Use the radius prop to assign a specific radius value.

<Flex gap="3">
	<Switch radius="none" defaultChecked />
	<Switch radius="small" defaultChecked />
	<Switch radius="full" defaultChecked />
</Flex>

Alignment

Composing Switch within Text automatically centers it with the first line of text.

Sync settings

Sync settings

Sync settings

<Flex direction="column" gap="3">
	<Text as="label" size="2">
		<Flex gap="2">
			<Switch size="1" defaultChecked /> Sync settings
		</Flex>
	</Text>

	<Text as="label" size="3">
		<Flex gap="2">
			<Switch size="2" defaultChecked /> Sync settings
		</Flex>
	</Text>

	<Text as="label" size="4">
		<Flex gap="2">
			<Switch size="3" defaultChecked /> Sync settings
		</Flex>
	</Text>
</Flex>

It is automatically well-aligned with multi-line text too.

Disabled

Use the native disabled attribute to create a disabled switch.

Off

On

On

Off

<Flex direction="column" gap="2">
	<Text as="label" size="2">
		<Flex gap="2">
			<Switch size="1" />
			Off
		</Flex>
	</Text>

	<Text as="label" size="2">
		<Flex gap="2">
			<Switch size="1" defaultChecked />
			On
		</Flex>
	</Text>

	<Text as="label" size="2" color="gray">
		<Flex gap="2">
			<Switch size="1" disabled />
			On
		</Flex>
	</Text>

	<Text as="label" size="2" color="gray">
		<Flex gap="2">
			<Switch size="1" disabled defaultChecked />
			Off
		</Flex>
	</Text>
</Flex>

PreviousSpinner

NextTable

Edit this page on GitHub.