List
Icons
API Reference
Root
cursor-pointer data-disabled:cursor-not-allowed data-disabled:opacity-50 flex gap-2
Property | Default | Type |
---|---|---|
element | - | Snippet<[{ attributes: Record<string, unknown>; }]> | undefinedRender the element yourself |
ids | - | Partial<{ root: string; hiddenInput: string; control: string; label: string; thumb: string; }> | undefinedThe ids of the elements in the switch. Useful for composition. |
label | - | string | undefinedSpecifies the localized strings that identifies the accessibility elements and their states |
disabled | - | boolean | undefinedWhether the switch is disabled. |
invalid | - | boolean | undefinedIf `true`, the switch is marked as invalid. |
required | - | boolean | undefinedIf `true`, the switch input is marked as required, |
readOnly | - | boolean | undefinedWhether the switch is read-only |
onCheckedChange | - | ((details: CheckedChangeDetails) => void) | undefinedFunction to call when the switch is clicked. |
checked | - | boolean | undefinedThe controlled checked state of the switch |
defaultChecked | - | boolean | undefinedThe initial checked state of the switch when rendered. Use when you don't need to control the checked state of the switch. |
name | - | string | undefinedThe name of the input field in a switch (Useful for form submission). |
form | - | string | undefinedThe id of the form that the switch belongs to |
value | "on" | string | number | undefinedThe value of switch input. Useful for form submission. |
dir | "ltr" | "ltr" | "rtl" | undefinedThe document's text/writing direction. |
getRootNode | - | (() => ShadowRoot | Node | Document) | undefinedA root node to correctly resolve document in custom environments. E.x.: Iframes, Electron. |
RootContext
Property | Default | Type |
---|---|---|
children | - | Snippet<[SwitchRootContextType]> |
Control
block preset-filled-surface-200-800 h-6 w-10 p-0.5 rounded-full flex justify-start data-[state=checked]:preset-filled-primary-500 data-focus:ring-2 data-focus:ring-surface-950-50
Property | Default | Type |
---|---|---|
element | - | Snippet<[{ attributes: Record<string, unknown>; }]> | undefinedRender the element yourself |
Thumb
rounded-full block preset-filled-surface-50-950 h-full aspect-square transition-transform grid place-items-center data-[state=checked]:bg-surface-950-50 data-[state=checked]:translate-x-4 rtl:data-[state=checked]:-translate-x-4
Property | Default | Type |
---|---|---|
element | - | Snippet<[{ attributes: Record<string, unknown>; }]> | undefinedRender the element yourself |
Label
Property | Default | Type |
---|---|---|
element | - | Snippet<[{ attributes: Record<string, unknown>; }]> | undefinedRender the element yourself |
HiddenInput
Property | Default | Type |
---|---|---|
element | - | Snippet<[{ attributes: Record<string, unknown>; }]> | undefinedRender the element yourself |