Switch

2 min read

Switch

Switch selector for when switching between two states, such as on and off, is required.

Usage

import { Switch } from '@antv/gui';

SwitchOptions

PropertyDescriptionTypeDefault
xThe x coordinate of the starting pointnumber-
yThe y coordinate of the starting pointnumber-
sizeSwitch the sizenumber22
spacingSwitch background spacingnumber2
textSpacingLeft-right spacing of text backgroundnumber8
styleCustom button stylesStyleAttr-
disabledDo not choosebooleanfalse
checkedSpecifies whether it is currently selectedboolean-
defaultCheckedInitial check or notbooleantrue
checkedChildrenThe content when selectedTagCfg-
unCheckedChildrenThe content when not selectedTagCfg-
onChangeCallback function when changefunction(checked: boolean)-
onClickCallback function when clickedfunction(e:Event, checked: boolean)-