1. components
  2. switch
  3. react

Switch

A control for toggling between checked states.

List



Icons

Pass icons as ReactNode to the inactiveChild and activeChild props respectively.

Icons

Apply the compact prop define a width for a minimal display.

Lightswitch

This is a full fledge example using multiple features.

API Reference

Switch

Property Type Description
id *
string
Set a unique ID for the switch input.
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.
labelledby
string
Identifies the element that labels the switch.
describedby
string
Identifies the element that describes the switch.
base
string
Set base classes for the root element.
stateInactive
string
Set inactive state classes for the root element.
stateActive
string
Set active state classes for the root element.
stateDisabled
string
Set disabled state classes for the root element.
width
string
Set width classes for the root element.
height
string
Set height classes for the root element.
padding
string
Set padding classes for the root element.
rounded
string
Set rounded classes for the root element.
hover
string
Set hover classes for the root element.
classes
string
Provide arbitrary classes to the root 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.
iconInactiveBase
string
Set base classes for the inactive icon child.
iconActiveBase
string
Set base classes for the active icon child.
onChange
object
Triggers when the switch is toggled.
inactiveChild
React.ReactNode
The inactive state children.
activeChild
React.ReactNode
The active state children.