Checkbox

A checkbox allows the user to select an option.

Props

Checkbox

size?

A checkbox can vary in size.

Defaults to md.
style?

The inline style for the element. A function may be provided to compute the style based on component state.

children?

The children of the component. A function may be provided to alter the children based on component state.

validationBehavior?

Whether to use native HTML form validation to prevent form submission when the value is missing or invalid, or mark the field as required or invalid via ARIA.

Defaults to 'native'.
isIndeterminate?

Indeterminism is presentational only. The indeterminate visual representation remains regardless of user interaction.

defaultSelected?

Whether the element should be selected (uncontrolled).

isSelected?

Whether the element should be selected (controlled).

onChange?

Handler that is called when the element's selection state changes.

value?

The value of the input element, used when submitting an HTML form. See MDN.

isDisabled?

Whether the input is disabled.

isReadOnly?

Whether the input can be selected but not changed by the user.

isRequired?

Whether user input is required on the input before form submission.

isInvalid?

Whether the input value is invalid.

validate?

A function that returns an error message if a given value is invalid. Validation errors are displayed to the user when the form is submitted if validationBehavior="native". For realtime validation, use the isInvalid prop instead.

autoFocus?

Whether the element should receive focus on render.

id?

The element's unique identifier. See MDN.

name?

The name of the input element, used when submitting an HTML form. See MDN.

inputRef?

A ref for the HTML input element.

className?

The CSS className for the element. A function may be provided to compute the class based on component state.

onFocus?

Handler that is called when the element receives focus.

onBlur?

Handler that is called when the element loses focus.

onFocusChange?

Handler that is called when the element's focus status changes.

onKeyDown?

Handler that is called when a key is pressed.

onKeyUp?

Handler that is called when a key is released.

onHoverStart?

Handler that is called when a hover interaction starts.

onHoverEnd?

Handler that is called when a hover interaction ends.

onHoverChange?

Handler that is called when the hover state changes.

aria-controls?

Identifies the element (or elements) whose contents or presence are controlled by the current element.

excludeFromTabOrder?

Whether to exclude the element from the sequential tab order. If true, the element will not be focusable via the keyboard by tabbing. This should be avoided except in rare scenarios where an alternative means of accessing the element or its functionality via the keyboard is available.

aria-label?

Defines a string value that labels the current element.

aria-labelledby?

Identifies the element (or elements) that labels the current element.

aria-describedby?

Identifies the element (or elements) that describes the object.

aria-details?

Identifies the element (or elements) that provide a detailed, extended description for the object.

aria-errormessage?

Identifies the element that provides an error message for the object.

slot?

A slot name for the component. Slots allow the component to receive props from a parent component. An explicit null value indicates that the local props completely override all props received from a parent.

CheckboxField

isDisabled?

Whether the checkbox field is disabled.

size?

A checkbox field can vary in size.

Defaults to md.
children?

The children of the component. A function may be provided to alter the children based on component state.

className?

The CSS className for the element. A function may be provided to compute the class based on component state.

style?

The inline style for the element. A function may be provided to compute the style based on component state.

aria-label?

Defines a string value that labels the current element.

aria-labelledby?

Identifies the element (or elements) that labels the current element.

aria-describedby?

Identifies the element (or elements) that describes the object.

aria-details?

Identifies the element (or elements) that provide a detailed, extended description for the object.

slot?

A slot name for the component. Slots allow the component to receive props from a parent component. An explicit null value indicates that the local props completely override all props received from a parent.

Anatomy

Composed Components

Checkbox

CheckboxField

Checkbox Examples

No Label

A checkbox can be rendered without a label.

Checked

A checkbox can be checked.

Indeterminate

A checkbox can be indeterminate.

Disabled

A checkbox can be disabled.

Read-only

A checkbox can be read-only.

Invalid

A checkbox can be invalid.

Sizes

A checkbox can vary in size.

Icon

A checkbox can be rendered with an icon or an icon list.

CheckboxField Examples

Disabled

A checkbox field can be disabled.

Sizes

A checkbox field can be rendered in a different size.

Description

A checkbox can have a description to provide more information to the user.

Migration Notes

Coming from Orbiter, you should be aware of the following changes:

  • onChange signature has been changed (no event are passed).
  • onValueChange has been deleted, use onChange instead.
  • checked has been renamed to isSelected.
  • disabled has been renamed to isDisabled.
  • required has been renamed to isRequired.
  • indeterminate has been renamed to isIndeterminate.
  • defaultIndeterminate prop has been removed.
  • The Counter component is no longer allowed as a specialized slot.
  • reverse is not supported, use flex-direction or row-reverse instead.
  • validationState has been removed. Use isInvalid instead. There is no isValid.
  • Values are not auto-generated when missed.