Switch

Switch UI Component

Based on Ant Design Switch

Demo

API

Props

PropertyDescriptionTypeDefault
autoFocusget focus when component mountedbooleanfalse
checkeddetermine whether the Switch is checkedbooleanfalse
checkedChildrencontent to be shown when the state is checkedstring / React.ReactNode-
classNameadditional class to Switchstring-
defaultCheckedto set the initial statebooleanfalse
disabledDisable switchbooleanfalse
descriptionSwitch descriptionstring-
errorTextError message, when provided changes switch stylestring-
labelswitch labelstring-
loadingloading state of switchbooleanfalse
onChangetrigger when the checked state is changing(checked: boolean, event: Event) => void-
onClicktrigger when clicked(checked: boolean, event: Event) => void-
unCheckedChildrencontent to be shown when the state is uncheckedstring / React.ReactNode-
sizethe size of the Switch,small / defaultdefault

Methods

NameDescription
blur()remove focus
focus()get focus