Checkbox

Displays a boolean value.

General

Change state with checked props.

Sizes

Checkbox of different sizes.

Type

Differentiate states by color.

Disable

Unusable and un-clickable Checkbox.

Group

Manage a set of Checkbox.

Accept terms

Keep the action disabled until the box is checked, so the next step is clear.

APIs

Checkbox.Props

AttributeDescriptionTypeAccepted valuesDefault
checkedchecked or notboolean--
initialCheckedchecked or not on initialboolean-false
onChangechange event handlerCheckboxEvent--
valueunique identification value (only in group)string--
disableddisable checkboxboolean-false
errormark the field as invalidboolean-false
errorMessagemessage below the fieldstring--
typecurrent typeCheckboxTypesCheckboxTypesdefault
refforwardRefRef<HTMLInputElement | null>--
...native propsLabelHTMLAttributes'form' ...-

Checkbox.Group.Props

AttributeDescriptionTypeAccepted valuesDefault
valuechecked childrenArray<string>-[]
disableddisable checkbox groupboolean-false
onChangechange event handler(values: string[]) => void--
...native propsHTMLAttributes'id', ...-

CheckboxTypes

type CheckboxTypes =
  | 'default'
  | 'primary'
  | 'secondary'
  | 'success'
  | 'warning'
  | 'error'
  | 'info'

CheckboxEvent

interface CheckboxEventTarget {
  checked: boolean
}

export interface CheckboxEvent {
  target: CheckboxEventTarget
  stopPropagation: () => void
  preventDefault: () => void
  nativeEvent: React.ChangeEvent
}

Ref

The ref points at the native input.

Accessibility

  • • The control is a native input of type checkbox, reached with Tab and changed with Space, with a visible focus ring.
  • • Put the label text inside the Checkbox so a click on it also changes the value.
Edit this page on GitHub