Switch is @(isChecked ? "on" : "off")
``` ## Styling ### Data Attributes | Attribute | Values | Description | |-----------|--------|-------------| | data-state | "checked" \| "unchecked" | Current state of the switch | | data-disabled | Present when disabled | Indicates disabled state | ### CSS Example ```css /* Switch root styles */ .switch { width: 2.75rem; height: 1.5rem; background: #e0e0e0; border-radius: 9999px; position: relative; border: none; cursor: pointer; transition: background 0.15s; } .switch[data-state="checked"] { background: #0066cc; } /* Thumb styles */ .switch-thumb { display: block; width: 1.25rem; height: 1.25rem; background: white; border-radius: 9999px; transition: transform 0.15s; transform: translateX(2px); } .switch[data-state="checked"] .switch-thumb { transform: translateX(calc(2.75rem - 1.25rem - 2px)); } ``` ## Accessibility ### Keyboard Navigation | Key | Action | |-----|--------| | Space / Enter | Toggles the switch state | ### ARIA Attributes - **role:** `switch` is set on the root element - **aria-checked:** Reflects the current state (`true` or `false`) - **aria-disabled:** Set when the switch is disabled