Skip to main content

Checkbox

Checkbox component.

When To Use#

  • Used for selecting multiple values from several options.
  • If you use only one checkbox, it is the same as using Switch to toggle between two states. The difference is that Switch will trigger the state change directly, but Checkbox just marks the state as changed and this needs to be submitted.

Examples#

import { Checkbox, CheckboxGroup } from 'tailor-ui';

Checkbox#

Basic#


Use with FormField#

this is a required field

Disabled#

CheckboxGroup#

Basic#


Controlled#


Composition render#


Direction#

Use with FormField#

API#

Checkbox#

PropertyDescriptionTypeDefault
checkedSpecifies whether the checkbox is selectedboolean
defaultCheckedSpecifies the initial state whether or not the checkbox is selected.boolean
disabledDisable Checkboxbooleanfalse
onChangeThe callback function that is triggered when the state changes(event: ChangeEvent) => void
valueThe value of checkboxstring
idThe id of checkboxstring
onFocus(event: FocusEvent) => void
onBlur(event: FocusEvent) => void

CheckboxGroup#

PropertyDescriptionTypeDefault
directionto specify the direction of the step bar'horizontal' 'vertical'
defaultValueTo set the initial valuestring[]
optionsSpecifies options{ label: ReactNode; value: string; disabled?: boolean; }[]
valueUsed for setting the currently selected valuestring[]
onChangeThe callback function that is triggered when the state changes(value: string[]) => void