Switch
The Switch is an alternative to the checkbox component.
Import
Importimport { Switch } from '@backyard-ui/core';Usage
UsageSize
SizeUse the size prop to increase the visual size.
States
StatesDisabled
DisabledInvalid
InvalidUsing with FormControl
Using with FormControlTo add a label or status message to your fields use the FormControl utility.
API Reference
API ReferenceRoot
Root- sizeDescription The Switch sizeType
"xs" | "sm" | "md"Defaultsm - isCheckedDescription If `true`, the checkbox will be checked. You'll need to pass onChange to update its value (since it is now controlled)Type
boolean - asChildDescriptionType
boolean - isDisabledDescription Set the form element to disabledType
boolean - isInvalidDescription Set the form element `aria-invalid` to `true`Type
boolean - isReadOnlyDescription Set the form element to readonlyType
boolean - isRequiredDescription Set the form element `aria-required` to `true`Type
boolean