Skip to main content

Switch

Switching Selector.

When To Use#

  • If you need to represent the switching between two states or on-off state.
  • The difference between Switch and Checkbox is that Switch will trigger a state change directly when you toggle it, while Checkbox is generally used for state marking, which should work in conjunction with submit operation.

Examples#

import { Switch } from 'tailor-ui';

With controlled#


With uncontrolled#

With disabled#


API#

PropertyDescriptionTypeDefault
checkeddetermine whether the Switch is checkedboolean
defaultCheckedto set the initial stateboolean
disabledDisable switchbooleanfalse
onChangea callback function, can be executed when the checked state is changing(checked: boolean) => void