Switch
A form component modeled after a hardware toggle switch to quickly commit binary settings.
For more information on this component configuration, visit Radix UI
Disabled
Use the disabled attr or the disabled class to disable an item component.
Sizes
Use the switch-{size} class to control the component size.
Size values can include:smmdlg.
For more information on all available sizing utilities, visit Tailwind
Palette
Use the palette-{color} class to control the component color. Refer to the Colors documentation to see all available color and shade options.
For more information on all available color utilities, visit Tailwind .
Customizing
globals.css
:root {
--ex-switch-cursor: default;
--ex-switch-height-sm: calc(var(--spacing) * 4);
--ex-switch-height-md: calc(var(--spacing) * 5);
--ex-switch-height-lg: calc(var(--spacing) * 6);
--ex-switch-width-sm: calc(var(--spacing) * 8);
--ex-switch-width-md: calc(var(--spacing) * 10);
--ex-switch-width-lg: calc(var(--spacing) * 12);
--ex-switch-radius-sm: 9999px;
--ex-switch-radius-md: 9999px;
--ex-switch-radius-lg: 9999px;
--ex-switch-thumb-mx: calc(var(--spacing) * 1);
--ex-switch-thumb-radius-sm: 9999px;
--ex-switch-thumb-radius-md: 9999px;
--ex-switch-thumb-radius-lg: 9999px;
--ex-switch-thumb-size-sm: calc(var(--spacing) * 2);
--ex-switch-thumb-size-md: calc(var(--spacing) * 3);
--ex-switch-thumb-size-lg: calc(var(--spacing) * 4);
}API
For more information on this component configuration, visit Radix UI
Switch
| Element | Selector |
|---|---|
Switch | .ex-switch |
| Prop | Type | Default |
|---|---|---|
asChild | boolean | false |
checked | boolean | false |
defaultChecked | boolean | false |
disabled | boolean | false |
name | string | |
required | boolean | false |
value | string | |
onCheckedChange | function |
Switch Thumb
| Element | Selector |
|---|---|
Switch.Thumb | .ex-switch-thumb |
| Prop | Type | Default |
|---|---|---|
as | ElementType | span |
asChild | boolean | false |
Last updated on