Switch - Skeleton

  1. components
  2. switch
  3. react

Switch

A control for toggling between checked states.

List

Default to the inactive state.


Default to the active state.


Shown in disabled mode.

Icons

Pass icons as React.Node elements to the inactiveChild and activeChild props respectively.

Icons

Apply the compact prop to switch a minimal display.

Lightswitch

This is a full fledge example using multiple features.

API Reference

Switch

Property Type Description
name *
string
Set a unique name for the switch input.
checked
boolean
Set the checked state.
disabled
boolean
Set the disabled state.
compact
boolean
Set the compact display mode.
base
string
Set base classes for the root element.
classes
string
Provide arbitrary classes to the root element.
stateFocused
string
Set claseses for the focus state.
controlBase
string
Set base classes for the control element.
controlInactive
string
Set inactive state classes for the control element.
controlActive
string
Set active state classes for the control element.
controlDisabled
string
Set disabled state classes for the control element.
controlWidth
string
Set width classes for the control element.
controlHeight
string
Set height classes for the control element.
controlPadding
string
Set padding classes for the control element.
controlRounded
string
Set rounded classes for the control element.
controlHover
string
Set hover classes for the control element.
controlClasses
string
Provide arbitrary classes to the control element.
thumbBase
string
Set base classes for the thumb element.
thumbInactive
string
Set inactive classes for the thumb element.
thumbActive
string
Set active classes for the thumb element.
thumbRounded
string
Set rounded classes for the thumb element.
thumbTranslateX
string
Set animation X-axis translate classes for the thumb element.
thumbTransition
string
Set animation transition classes for the thumb element.
thumbEase
string
Set animation easing classes for the thumb element.
thumbDuration
string
Set animation duration classes for the thumb element.
thumbClasses
string
Provide arbitrary classes to the thumb element.
labelBase
string
Set base classes for the label element.
labelClasses
string
Provide arbitrary classes to the label element.
iconInactiveBase
string
Set base classes for the inactive icon child.
iconActiveBase
string
Set base classes for the active icon child.
onCheckedChange
Triggers when the switch is toggled.
inactiveChild
ReactNode
The inactive state children.
activeChild
ReactNode
The active state children.
children
ReactNode
ids
The ids of the elements in the switch. Useful for composition.
label
string
Specifies the localized strings that identifies the accessibility elements and their states
invalid
boolean
If `true`, the switch is marked as invalid.
required
boolean
If `true`, the switch input is marked as required,
readOnly
boolean
Whether the switch is read-only
form
string
The id of the form that the switch belongs to
value
string | number
The value of switch input. Useful for form submission.
Default: "on"
dir
"ltr" | "rtl"
The document's text/writing direction.
Default: "ltr"
getRootNode
A root node to correctly resolve document in custom environments. E.x.: Iframes, Electron.