Form Components
[03] Form Components
Switch
Switch toggles a setting that takes effect immediately. Use Checkbox instead when the value is submitted with a form.
Switch takes the same checked, defaultChecked, onChange, name and readOnly props as Checkbox, so choosing between the two comes down to when the change applies. Its knob is decorative markup marked aria-hidden. Pass switch to a Field to render a Switch with its label beside it.
Basic usage
Switch toggles a setting that takes effect immediately. It renders a real checkbox input with role="switch", so it is operable with the keyboard and announced correctly.
<Label row itemsCenter> <Switch defaultChecked/> Email notifications</Label>Sizes
A Switch inside a Label inherits the Label's size, so set it once.
<Col> <Label row itemsCenter xs><Switch defaultChecked/> Extra small</Label> <Label row itemsCenter sm><Switch defaultChecked/> Small</Label> <Label row itemsCenter md><Switch defaultChecked/> Medium</Label> <Label row itemsCenter lg><Switch defaultChecked/> Large</Label> <Label row itemsCenter xl><Switch defaultChecked/> Extra large</Label></Col>Appearances
The appearance colours the track when the switch is on, and the focus ring.
<Row flexWrap> <Label row itemsCenter><Switch defaultChecked/> primary (default)</Label> <Label row itemsCenter accent><Switch accent defaultChecked/> accent</Label> <Label row itemsCenter secondary><Switch secondary defaultChecked/> secondary</Label> <Label row itemsCenter tertiary><Switch tertiary defaultChecked/> tertiary</Label> <Label row itemsCenter success><Switch success defaultChecked/> success</Label> <Label row itemsCenter danger><Switch danger defaultChecked/> danger</Label> <Label row itemsCenter warning><Switch warning defaultChecked/> warning</Label> <Label row itemsCenter info><Switch info defaultChecked/> info</Label></Row>Shapes
Switch is pill by default. The shape applies to the track and the knob together: the knob's corner radius insets from the track's by the track padding, so the two stay concentric instead of a round knob sitting in a square track.
<Col> <Label row itemsCenter><Switch defaultChecked/> pill, the default</Label> <Label row itemsCenter><Switch rounded defaultChecked/> rounded</Label> <Label row itemsCenter><Switch sharp defaultChecked/> sharp</Label></Col>Variants
Switch is filled by default: the track fills with the appearance colour when on. outline keeps the track transparent and colours its border instead.
<Col> <Label row itemsCenter><Switch defaultChecked/> filled, the default</Label> <Label row itemsCenter><Switch outline defaultChecked/> outline</Label> <Label row itemsCenter><Switch ghost defaultChecked/> ghost</Label></Col>Explicit size on the control
The Switch takes its own size prop, which wins over the size inherited from the Label.
<Col> <Label row itemsCenter lg><Switch xs defaultChecked/> xs track, lg label</Label> <Label row itemsCenter lg><Switch defaultChecked/> inherited lg</Label> <Label row itemsCenter lg><Switch xl defaultChecked/> xl track, lg label</Label></Col>States
A readOnly switch keeps its value when clicked and dims like a read-only text field; Checkbox and Radio behave the same way.
<Col> <Label row itemsCenter><Switch/> Off</Label> <Label row itemsCenter><Switch defaultChecked/> On</Label> <Label row itemsCenter><Switch disabled/> Disabled</Label> <Label row itemsCenter><Switch disabled defaultChecked/> Disabled and on</Label> <Label row itemsCenter><Switch readOnly defaultChecked/> Read-only</Label></Col>Switch Props
| Prop | Category | Default | Description |
|---|---|---|---|
accent | Appearance | Accent color appearance (rose) | |
danger | Appearance | Danger color appearance (red) | |
info | Appearance | Info color appearance (cyan) | |
inheritAppearance | Appearance | Inherit appearance from parent — suppresses own data-appearance/data-variant, uses parent's CSS variables | |
primary | Appearance | ✓ | Primary color appearance (gray) |
secondary | Appearance | Secondary color appearance (gray) | |
success | Appearance | Success color appearance (green) | |
tertiary | Appearance | Tertiary color appearance | |
warning | Appearance | Warning color appearance (amber) | |
disabled | Disabled | Disable the component — reduces opacity, changes cursor to not-allowed, and prevents interaction | |
readOnly | Read Only | Render the field read-only — mutes it (lighter than disabled) and sets a default cursor; the value stays selectable and submittable | |
pill | Shape | ✓ | Fully rounded corners (circular) |
rounded | Shape | Medium rounded corners (default) | |
sharp | Shape | No rounded corners (square) | |
lg | Size | Large size | |
md | Size | ✓ | Medium size (default) |
sm | Size | Small size | |
xl | Size | Extra large size | |
xs | Size | Extra small size | |
invalid | Validity | Mark the field invalid (red border/ring), layered over any appearance | |
filled | Variant | ✓ | Filled variant - solid background with contrasting text color |
ghost | Variant | Ghost variant - transparent background, no border, appearance-colored text, tinted hover background | |
outline | Variant | Outline variant - transparent background with border and colored text (default) |
Layout & utility props (gap, padding, hide, items, justify, ...) — documented on Common Props
| Prop | Category | Default | Description |
|---|---|---|---|
alignSelfAuto | Align Self | Use the parent's align-items value (align-self: auto) | |
alignSelfBaseline | Align Self | Align this item to its baseline (align-self: baseline) | |
alignSelfCenter | Align Self | Center this item on the cross axis (align-self: center) | |
alignSelfEnd | Align Self | Align this item to the end of the cross axis (align-self: flex-end) | |
alignSelfStart | Align Self | Align this item to the start of the cross axis (align-self: flex-start) | |
alignSelfStretch | Align Self | Stretch this item to fill the cross axis (align-self: stretch) | |
border | Border | ✓ | Enable border on all sides |
borderB | Border | Enable border on bottom | |
borderEnd | Border | Enable border on the inline-end side (right in LTR, left in RTL) | |
borderL | Border | Enable border on left | |
borderR | Border | Enable border on right | |
borderStart | Border | Enable border on the inline-start side (left in LTR, right in RTL) | |
borderT | Border | Enable border on top | |
borderX | Border | Enable border on left and right | |
borderY | Border | Enable border on top and bottom | |
noBorder | Border | Disable all borders | |
cursorDefault | Cursor | Default cursor - standard arrow | |
cursorMove | Cursor | Move cursor - indicates draggable element | |
cursorNone | Cursor | No cursor - hides the cursor | |
cursorNotAllowed | Cursor | Not-allowed cursor - indicates disabled state | |
cursorPointer | Cursor | ✓ | Pointer cursor - indicates clickable element |
cursorText | Cursor | Text cursor - indicates selectable text | |
cursorWait | Cursor | Wait cursor - indicates loading/processing | |
block | Display | Block display - takes full width, new line | |
contents | Display | Contents display - element's box is removed, children display as if parent didn't exist | |
flex | Display | Flex display - flexbox container | |
grid | Display | Grid display - CSS grid container | |
hidden | Display | Hidden display - element is not visible | |
inline | Display | Inline display - flows with text | |
inlineBlock | Display | Inline-block display - inline but with block properties | |
inlineFlex | Display | Inline-flex display - inline flexbox container | |
inlineGrid | Display | Inline-grid display - inline grid container | |
table | Display | Table display - behaves like table element | |
tableCell | Display | Table-cell display - behaves like td element | |
focusVisible | Focus Visible | ✓ | Enable focus-visible outline |
noFocusVisible | Focus Visible | Disable focus-visible outline | |
hAuto | Height | Set height to auto | |
hFit | Height | Set height to fit-content | |
hFull | Height | Set height to 100% | |
hScreen | Height | Set height to 100vh (viewport height), removes max-height constraint | |
desktopHide | Hide | Hide element on desktop devices and below (max-desktop: 80rem) | |
mobileHide | Hide | Hide element on mobile devices and below (max-mobile: 48rem) | |
tabletHide | Hide | Hide element on tablet devices and below (max-tablet: 64rem) | |
itemsBaseline | Items | Align items to baseline | |
itemsCenter | Items | Align items to center | |
itemsEnd | Items | Align items to end (bottom/right) | |
itemsStart | Items | Align items to start (top/left) | |
itemsStretch | Items | Stretch items to fill container | |
justifyAround | Justify | Distribute items with space around them | |
justifyBaseline | Justify | Align items along their baseline on main axis | |
justifyBetween | Justify | Distribute items with space between them | |
justifyCenter | Justify | Center items along the main axis | |
justifyEnd | Justify | Pack items toward the end of the main axis | |
justifyEvenly | Justify | Distribute items with equal space around them | |
justifyStart | Justify | Pack items toward the start of the main axis | |
justifyStretch | Justify | Stretch items to fill the main axis | |
overflowAuto | Overflow | Auto overflow - show scrollbars if needed | |
overflowClip | Overflow | Clip overflow - hard clip without scrollbars | |
overflowHidden | Overflow | Hidden overflow - clip content without scrollbars | |
overflowScroll | Overflow | Scroll overflow - always show scrollbars | |
overflowVisible | Overflow | Visible overflow - content extends beyond bounds | |
overflowXAuto | Overflow | Auto overflow on X-axis only | |
overflowXClip | Overflow | Clip overflow on X-axis only | |
overflowXHidden | Overflow | Hidden overflow on X-axis only | |
overflowXScroll | Overflow | Scroll overflow on X-axis only | |
overflowXVisible | Overflow | Visible overflow on X-axis only | |
overflowYAuto | Overflow | Auto overflow on Y-axis only | |
overflowYClip | Overflow | Clip overflow on Y-axis only | |
overflowYHidden | Overflow | Hidden overflow on Y-axis only | |
overflowYScroll | Overflow | Scroll overflow on Y-axis only | |
overflowYVisible | Overflow | Visible overflow on Y-axis only | |
absolute | Position | Absolute positioning | |
fixed | Position | Fixed positioning | |
relative | Position | Relative positioning | |
static | Position | Static positioning | |
sticky | Position | Sticky positioning at the top edge; set --sticky-top to stick below a fixed header | |
responsiveSizing | Responsive Sizing | Enable responsive sizing - uses breakpoint-specific classes for font size, padding, and gap | |
desktopWFull | Responsive Width | Set width to 100% on desktop and below, below 1280px (max-desktop: 80rem) | |
mobileWFull | Responsive Width | Set width to 100% on mobile, below 768px (max-mobile: 48rem) | |
tabletWFull | Responsive Width | Set width to 100% on tablet and below, below 1024px (max-tablet: 64rem) | |
insetRing | Ring | Enable the inset ring — emits ring-inset | |
noInsetRing | Ring | ✓ | Disable the inset ring |
noShadow | Shadow | ✓ | Disable drop shadow |
shadow | Shadow | Enable drop shadow at the component's size | |
shadowLg | Shadow | Large drop shadow, whatever the component's size | |
shadowMd | Shadow | Medium drop shadow, whatever the component's size | |
shadowSm | Shadow | Small drop shadow, whatever the component's size | |
shadowXl | Shadow | Extra-large drop shadow, whatever the component's size | |
shadowXs | Shadow | Extra-small drop shadow, whatever the component's size | |
desktopShow | Show | Show element only on desktop and below, below 1280px (hidden from 80rem up) | |
mobileShow | Show | Show element only on mobile, below 768px (hidden from 48rem up) | |
tabletShow | Show | Show element only on tablet and below, below 1024px (hidden from 64rem up) | |
noTransition | Transition | Disable transitions for instant state changes | |
transition | Transition | ✓ | Enable smooth transitions between states |
transparent | Transparent | Disable background color - makes component background transparent | |
wAuto | Width | Set width to auto | |
wFit | Width | Set width to fit-content | |
wFull | Width | Set width to 100% | |
wScreen | Width | Set width to 100vw (viewport width), removes max-width constraint |