Flutter docs
Default skin

Checkbox

Collect user's choices.

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

Basic

Basic usage of checkbox.

Controlled Checkbox

Communicated with other components.

Check all

The indeterminate property can help you to achieve a 'check all' effect.

Custom semantic dom styling

You can customize the semantic dom style of Checkbox by passing objects/functions through classNames and styles.

Disabled

Disabled checkbox.

Checkbox Group

Generate a group of checkboxes from an array.

Use with Grid

We can use Checkbox and Grid in Checkbox.Group, to implement complex layout.

API

Checkbox and Checkbox.Group are exported from @ceebee/ui/client.

Checkbox

PropertyDescriptionTypeDefaultVersion
checkedSpecifies whether the checkbox is selectedbooleanfalse—
classNamesCustomize class for each semantic structure inside the component. Supports object or function.Record<SemanticDOM, string> | (info: { props })=> Record<SemanticDOM, string>-—
defaultCheckedSpecifies the initial state: whether or not the checkbox is selectedbooleanfalse—
disabledIf disable checkboxbooleanfalse—
indeterminateThe indeterminate checked state of checkboxbooleanfalse—
onChangeThe callback function that is triggered when the state changes(e: CheckboxChangeEvent) => void-—
onBlurCalled when leaving the componentfunction()-—
onFocusCalled when entering the componentfunction()-—
stylesCustomize inline style for each semantic structure inside the component. Supports object or function.Record<SemanticDOM, CSSProperties> | (info: { props })=> Record<SemanticDOM, CSSProperties>-—
defaultValueDefault selected value(string | number)\[]\[]—
disabledIf disable all checkboxesbooleanfalse—
nameThe name property of all input[type="checkbox"] childrenstring-—
optionsSpecifies optionsstring\[] | number\[] | Option\[]\[]—
valueUsed for setting the currently selected value(string | number | boolean)\[]\[]—
titletitle of the optionstring-—
classNameclassName of the optionstring-5.25.0
stylestyles of the optionReact.CSSProperties-—
onChangeThe callback function that is triggered when the state changes(checkedValue: T[]) => void-—