Skip to content

Events#

TypeDescription
onChange({ checked: boolean; event }) => void(optional) Will be called on state changes made by the user.
onChangeEnd({ checked: boolean; event }) => void(optional) Will be called on state changes made by the user, but with a delay. This way the user sees the animation before e.g. an error will be removed. Returns a boolean { checked, event }.
onClick({ checked: boolean; event: MouseEvent, preventDefault: () => void }) => void(optional) Will be called on click.
onKeyDown(event: React.KeyboardEvent<HTMLInputElement>) => void(optional) Will be called when a key is pressed while the switch has focus. Call event.preventDefault() to keep the switch from toggling on Enter.
onKeyUp(event: React.KeyboardEvent<HTMLInputElement>) => void(optional) Will be called when a key is released while the switch has focus.
Suggest an edit