Form

Checkbox

A set of checkboxes allow users to select multiple options from a list. A single checkbox can be used to enable/disable an option.
1
import {Checkbox, Label} from '@coveord/plasma-react';
2
import {useState} from 'react';
3
4
const Demo = () => {
5
const [checked, setChecked] = useState(false);
6
return (
7
<Checkbox checked={checked} onClick={() => setChecked(!checked)}>
8
<Label>Label</Label>
9
</Checkbox>
10
);
11
};
12
export default Demo;

Props

NameTypeDefaultDescription
"aria-activedescendant"string
Identifies the currently active element when DOM focus is on a composite widget, textbox, group, or application.
"aria-atomic"Booleanish
Indicates whether assistive technologies will present all, or only parts of, the changed region based on the change notifications defined by the aria-relevant attribute.
"aria-autocomplete""list" | "none" | "inline" | "both"
Indicates whether inputting text could trigger display of one or more predictions of the user's intended value for an input and specifies how predictions would be presented if they are made.
"aria-braillelabel"string
Defines a string value that labels the current element, which is intended to be converted into Braille.
"aria-brailleroledescription"string
Defines a human-readable, author-localized abbreviated description for the role of an element, which is intended to be converted into Braille.
"aria-busy"Booleanish
"aria-checked"boolean | "true" | "false" | "mixed"
Indicates the current "checked" state of checkboxes, radio buttons, and other widgets.
"aria-colcount"number
Defines the total number of columns in a table, grid, or treegrid.
"aria-colindex"number
Defines an element's column index or position with respect to the total number of columns within a table, grid, or treegrid.
"aria-colindextext"string
Defines a human readable text alternative of aria-colindex.
"aria-colspan"number
Defines the number of columns spanned by a cell or gridcell within a table, grid, or treegrid.
"aria-controls"string
Identifies the element (or elements) whose contents or presence are controlled by the current element.
"aria-current"boolean | "step" | "true" | "false" | "page" | "location" | "date" | "time"
Indicates the element that represents the current item within a container or set of related elements.
"aria-describedby"string
Identifies the element (or elements) that describes the object.
"aria-description"string
Defines a string value that describes or annotates the current element.
"aria-details"string
Identifies the element that provides a detailed, extended description for the object.
"aria-disabled"Booleanish
Indicates that the element is perceivable but disabled, so it is not editable or otherwise operable.
"aria-errormessage"string
Identifies the element that provides an error message for the object.
"aria-expanded"Booleanish
Indicates whether the element, or another grouping element it controls, is currently expanded or collapsed.
"aria-flowto"string
Identifies the next element (or elements) in an alternate reading order of content which, at the user's discretion, allows assistive technology to override the general default of reading in document source order.
"aria-haspopup"boolean | "true" | "false" | "menu" | "listbox" | "tree" | "grid" | "dialog"
Indicates the availability and type of interactive popup element, such as menu or dialog, that can be triggered by an element.
"aria-hidden"Booleanish
Indicates whether the element is exposed to an accessibility API.
"aria-invalid"boolean | "true" | "false" | "grammar" | "spelling"
Indicates the entered value does not conform to the format expected by the application.
"aria-keyshortcuts"string
Indicates keyboard shortcuts that an author has implemented to activate or give focus to an element.
"aria-label"string
Defines a string value that labels the current element.
"aria-labelledby"string
The id of the element that gives a label to this checkbox. Not needed when using the Label component in the checkbox's children.
"aria-level"number
Defines the hierarchical level of an element within a structure.
"aria-live""off" | "assertive" | "polite"
Indicates that an element will be updated, and describes the types of updates the user agents, assistive technologies, and user can expect from the live region.
"aria-modal"Booleanish
Indicates whether an element is modal when displayed.
"aria-multiline"Booleanish
Indicates whether a text box accepts multiple lines of input or only a single line.
"aria-multiselectable"Booleanish
Indicates that the user may select more than one item from the current selectable descendants.
"aria-orientation""horizontal" | "vertical"
Indicates whether the element's orientation is horizontal, vertical, or unknown/ambiguous.
"aria-owns"string
Identifies an element (or elements) in order to define a visual, functional, or contextual parent/child relationship between DOM elements where the DOM hierarchy cannot be used to represent the relationship.
"aria-placeholder"string
Defines a short hint (a word or short phrase) intended to aid the user with data entry when the control has no value. A hint could be a sample value or a brief description of the expected format.
"aria-posinset"number
Defines an element's number or position in the current set of listitems or treeitems. Not required if all elements in the set are present in the DOM.
"aria-pressed"boolean | "true" | "false" | "mixed"
Indicates the current "pressed" state of toggle buttons.
"aria-readonly"Booleanish
Indicates that the element is not editable, but is otherwise operable.
"aria-relevant""additions" | "additions removals" | "additions text" | "all" | "removals" | "removals additions" | "removals text" | "text" | "text additions" | "text removals"
Indicates what notifications the user agent will trigger when the accessibility tree within a live region is modified.
"aria-required"Booleanish
Indicates that user input is required on the element before a form may be submitted.
"aria-roledescription"string
Defines a human-readable, author-localized description for the role of an element.
"aria-rowcount"number
Defines the total number of rows in a table, grid, or treegrid.
"aria-rowindex"number
Defines an element's row index or position with respect to the total number of rows within a table, grid, or treegrid.
"aria-rowindextext"string
Defines a human readable text alternative of aria-rowindex.
"aria-rowspan"number
Defines the number of rows spanned by a cell or gridcell within a table, grid, or treegrid.
"aria-selected"Booleanish
Indicates the current "selected" state of various widgets.
"aria-setsize"number
Defines the number of items in the current set of listitems or treeitems. Not required if all elements in the set are present in the DOM.
"aria-sort""none" | "ascending" | "descending" | "other"
Indicates if items in a table or grid are sorted in ascending or descending order.
"aria-valuemax"number
Defines the maximum allowed value for a range widget.
"aria-valuemin"number
Defines the minimum allowed value for a range widget.
"aria-valuenow"number
Defines the current value for a range widget.
"aria-valuetext"string
Defines the human readable text alternative of aria-valuenow for a range widget.
aboutstring
acceptstring
acceptCharsetstring
accessKeystring
actionstring
allowFullScreenboolean
allowTransparencyboolean
altstring
asstring
asyncboolean
autoCapitalizestring
autoCompletestring
autoCorrectstring
autoFocusboolean
autoPlayboolean
autoSavestring
captureboolean | "user" | "environment"
cellPaddingstring | number
cellSpacingstring | number
challengestring
changeDirtyState(value?: string, valid?: boolean) => void
charSetstring
checkedboolean
childrenReactNode
citestring
classesIClassName
classIDstring
classNamestring
clearSidesboolean
Makes the checkbox stand on its own line
colorstring
colsnumber
colSpannumber
contentstring
contentEditableBooleanish | "inherit"
contextMenustring
controlsboolean
coordsstring
crossOriginCrossOrigin
dangerouslySetInnerHTML{ __html: string | TrustedHTML; }
datastring
datatypestring
dateTimestring
defaultboolean
defaultCheckedboolean
defaultDisabledboolean
Whether the checkbox is disabled initially. Only useful with connected checkboxes because their disabled state is managed by the PlasmaState.
defaultValuestring
deferboolean
dirstring
disabledboolean
disabledOnMountboolean
disabledTooltipstring
downloadany
draggableBooleanish
encTypestring
formstring
formActionstring
formEncTypestring
formMethodstring
formNoValidateboolean
formTargetstring
frameBorderstring | number
handleOnClick(wasChecked: boolean) => void
A callback function that gets executed after the checkbox is clicked
  • wasChecked–Whether the checkbox was checked before it got toggled
headersstring
heightstring | number
hiddenboolean
highnumber
hrefstring
hrefLangstring
htmlForstring
httpEquivstring
idstring
indeterminateboolean
inlistany
innerInputClassesIClassName
inputMode"none" | "text" | "tel" | "url" | "email" | "numeric" | "decimal" | "search"
Hints at the type of data that might be entered by the user while editing the element or its contents
integritystring
isstring
Specify that a standard HTML element should behave like a defined custom built-in element
isReadOnlyboolean
itemIDstring
itemPropstring
itemRefstring
itemScopeboolean
itemTypestring
keyParamsstring
keyTypestring
kindstring
labelstring
labelPropsILabelProps
labelTitleReactNode
langstring
liststring
loopboolean
lownumber
manifeststring
marginHeightnumber
marginWidthnumber
maxstring | number
maximumnumber
maxLengthnumber
mediastring
mediaGroupstring
methodstring
minstring | number
minimumnumber
minLengthnumber
multipleboolean
mutedboolean
namestring
noncestring
noValidateboolean
onAbortReactEventHandler<HTMLInputElement>
onAbortCaptureReactEventHandler<HTMLInputElement>
onAnimationEndAnimationEventHandler<HTMLInputElement>
onAnimationEndCaptureAnimationEventHandler<HTMLInputElement>
onAnimationIterationAnimationEventHandler<HTMLInputElement>
onAnimationIterationCaptureAnimationEventHandler<HTMLInputElement>
onAnimationStartAnimationEventHandler<HTMLInputElement>
onAnimationStartCaptureAnimationEventHandler<HTMLInputElement>
onAuxClickMouseEventHandler<HTMLInputElement>
onAuxClickCaptureMouseEventHandler<HTMLInputElement>
onBeforeInputFormEventHandler<HTMLInputElement>
onBeforeInputCaptureFormEventHandler<HTMLInputElement>
onBlur(value: string) => void
onBlurCaptureFocusEventHandler<HTMLInputElement>
onCanPlayReactEventHandler<HTMLInputElement>
onCanPlayCaptureReactEventHandler<HTMLInputElement>
onCanPlayThroughReactEventHandler<HTMLInputElement>
onCanPlayThroughCaptureReactEventHandler<HTMLInputElement>
onChange(value?: string, valid?: boolean) => void
onChangeCaptureFormEventHandler<HTMLInputElement>
onChangeHandlerChangeEventHandler<HTMLInputElement>
onClick(e: MouseEvent<HTMLElement, MouseEvent>) => void
onClickCaptureMouseEventHandler<HTMLInputElement>
onCompositionEndCompositionEventHandler<HTMLInputElement>
onCompositionEndCaptureCompositionEventHandler<HTMLInputElement>
onCompositionStartCompositionEventHandler<HTMLInputElement>
onCompositionStartCaptureCompositionEventHandler<HTMLInputElement>
onCompositionUpdateCompositionEventHandler<HTMLInputElement>
onCompositionUpdateCaptureCompositionEventHandler<HTMLInputElement>
onContextMenuMouseEventHandler<HTMLInputElement>
onContextMenuCaptureMouseEventHandler<HTMLInputElement>
onCopyClipboardEventHandler<HTMLInputElement>
onCopyCaptureClipboardEventHandler<HTMLInputElement>
onCutClipboardEventHandler<HTMLInputElement>
onCutCaptureClipboardEventHandler<HTMLInputElement>
onDestroy() => void
onDoubleClickMouseEventHandler<HTMLInputElement>
onDoubleClickCaptureMouseEventHandler<HTMLInputElement>
onDragDragEventHandler<HTMLInputElement>
onDragCaptureDragEventHandler<HTMLInputElement>
onDragEndDragEventHandler<HTMLInputElement>
onDragEndCaptureDragEventHandler<HTMLInputElement>
onDragEnterDragEventHandler<HTMLInputElement>
onDragEnterCaptureDragEventHandler<HTMLInputElement>
onDragExitDragEventHandler<HTMLInputElement>
onDragExitCaptureDragEventHandler<HTMLInputElement>
onDragLeaveDragEventHandler<HTMLInputElement>
onDragLeaveCaptureDragEventHandler<HTMLInputElement>
onDragOverDragEventHandler<HTMLInputElement>
onDragOverCaptureDragEventHandler<HTMLInputElement>
onDragStartDragEventHandler<HTMLInputElement>
onDragStartCaptureDragEventHandler<HTMLInputElement>
onDropDragEventHandler<HTMLInputElement>
onDropCaptureDragEventHandler<HTMLInputElement>
onDurationChangeReactEventHandler<HTMLInputElement>
onDurationChangeCaptureReactEventHandler<HTMLInputElement>
onEmptiedReactEventHandler<HTMLInputElement>
onEmptiedCaptureReactEventHandler<HTMLInputElement>
onEncryptedReactEventHandler<HTMLInputElement>
onEncryptedCaptureReactEventHandler<HTMLInputElement>
onEndedReactEventHandler<HTMLInputElement>
onEndedCaptureReactEventHandler<HTMLInputElement>
onErrorReactEventHandler<HTMLInputElement>
onErrorCaptureReactEventHandler<HTMLInputElement>
onFocusFocusEventHandler<HTMLInputElement>
onFocusCaptureFocusEventHandler<HTMLInputElement>
onGotPointerCapturePointerEventHandler<HTMLInputElement>
onGotPointerCaptureCapturePointerEventHandler<HTMLInputElement>
onInputFormEventHandler<HTMLInputElement>
onInputCaptureFormEventHandler<HTMLInputElement>
onInvalidFormEventHandler<HTMLInputElement>
onInvalidCaptureFormEventHandler<HTMLInputElement>
onKeyDownKeyboardEventHandler<HTMLInputElement>
onKeyDownCaptureKeyboardEventHandler<HTMLInputElement>
onKeyUpKeyboardEventHandler<HTMLInputElement>
onKeyUpCaptureKeyboardEventHandler<HTMLInputElement>
onLoadReactEventHandler<HTMLInputElement>
onLoadCaptureReactEventHandler<HTMLInputElement>
onLoadedDataReactEventHandler<HTMLInputElement>
onLoadedDataCaptureReactEventHandler<HTMLInputElement>
onLoadedMetadataReactEventHandler<HTMLInputElement>
onLoadedMetadataCaptureReactEventHandler<HTMLInputElement>
onLoadStartReactEventHandler<HTMLInputElement>
onLoadStartCaptureReactEventHandler<HTMLInputElement>
onLostPointerCapturePointerEventHandler<HTMLInputElement>
onLostPointerCaptureCapturePointerEventHandler<HTMLInputElement>
onMouseDownMouseEventHandler<HTMLInputElement>
onMouseDownCaptureMouseEventHandler<HTMLInputElement>
onMouseEnterMouseEventHandler<HTMLInputElement>
onMouseLeaveMouseEventHandler<HTMLInputElement>
onMouseMoveMouseEventHandler<HTMLInputElement>
onMouseMoveCaptureMouseEventHandler<HTMLInputElement>
onMouseOutMouseEventHandler<HTMLInputElement>
onMouseOutCaptureMouseEventHandler<HTMLInputElement>
onMouseOverMouseEventHandler<HTMLInputElement>
onMouseOverCaptureMouseEventHandler<HTMLInputElement>
onMouseUpMouseEventHandler<HTMLInputElement>
onMouseUpCaptureMouseEventHandler<HTMLInputElement>
onPasteClipboardEventHandler<HTMLInputElement>
onPasteCaptureClipboardEventHandler<HTMLInputElement>
onPauseReactEventHandler<HTMLInputElement>
onPauseCaptureReactEventHandler<HTMLInputElement>
onPlayReactEventHandler<HTMLInputElement>
onPlayCaptureReactEventHandler<HTMLInputElement>
onPlayingReactEventHandler<HTMLInputElement>
onPlayingCaptureReactEventHandler<HTMLInputElement>
onPointerCancelPointerEventHandler<HTMLInputElement>
onPointerCancelCapturePointerEventHandler<HTMLInputElement>
onPointerDownPointerEventHandler<HTMLInputElement>
onPointerDownCapturePointerEventHandler<HTMLInputElement>
onPointerEnterPointerEventHandler<HTMLInputElement>
onPointerEnterCapturePointerEventHandler<HTMLInputElement>
onPointerLeavePointerEventHandler<HTMLInputElement>
onPointerLeaveCapturePointerEventHandler<HTMLInputElement>
onPointerMovePointerEventHandler<HTMLInputElement>
onPointerMoveCapturePointerEventHandler<HTMLInputElement>
onPointerOutPointerEventHandler<HTMLInputElement>
onPointerOutCapturePointerEventHandler<HTMLInputElement>
onPointerOverPointerEventHandler<HTMLInputElement>
onPointerOverCapturePointerEventHandler<HTMLInputElement>
onPointerUpPointerEventHandler<HTMLInputElement>
onPointerUpCapturePointerEventHandler<HTMLInputElement>
onProgressReactEventHandler<HTMLInputElement>
onProgressCaptureReactEventHandler<HTMLInputElement>
onRateChangeReactEventHandler<HTMLInputElement>
onRateChangeCaptureReactEventHandler<HTMLInputElement>
onRender(value?: string, valid?: boolean, disabled?: boolean) => void
onResetFormEventHandler<HTMLInputElement>
onResetCaptureFormEventHandler<HTMLInputElement>
onResizeReactEventHandler<HTMLInputElement>
onResizeCaptureReactEventHandler<HTMLInputElement>
onScrollUIEventHandler<HTMLInputElement>
onScrollCaptureUIEventHandler<HTMLInputElement>
onSeekedReactEventHandler<HTMLInputElement>
onSeekedCaptureReactEventHandler<HTMLInputElement>
onSeekingReactEventHandler<HTMLInputElement>
onSeekingCaptureReactEventHandler<HTMLInputElement>
onSelectReactEventHandler<HTMLInputElement>
onSelectCaptureReactEventHandler<HTMLInputElement>
onStalledReactEventHandler<HTMLInputElement>
onStalledCaptureReactEventHandler<HTMLInputElement>
onSubmitFormEventHandler<HTMLInputElement>
onSubmitCaptureFormEventHandler<HTMLInputElement>
onSuspendReactEventHandler<HTMLInputElement>
onSuspendCaptureReactEventHandler<HTMLInputElement>
onTimeUpdateReactEventHandler<HTMLInputElement>
onTimeUpdateCaptureReactEventHandler<HTMLInputElement>
onTouchCancelTouchEventHandler<HTMLInputElement>
onTouchCancelCaptureTouchEventHandler<HTMLInputElement>
onTouchEndTouchEventHandler<HTMLInputElement>
onTouchEndCaptureTouchEventHandler<HTMLInputElement>
onTouchMoveTouchEventHandler<HTMLInputElement>
onTouchMoveCaptureTouchEventHandler<HTMLInputElement>
onTouchStartTouchEventHandler<HTMLInputElement>
onTouchStartCaptureTouchEventHandler<HTMLInputElement>
onTransitionEndTransitionEventHandler<HTMLInputElement>
onTransitionEndCaptureTransitionEventHandler<HTMLInputElement>
onVolumeChangeReactEventHandler<HTMLInputElement>
onVolumeChangeCaptureReactEventHandler<HTMLInputElement>
onWaitingReactEventHandler<HTMLInputElement>
onWaitingCaptureReactEventHandler<HTMLInputElement>
onWheelWheelEventHandler<HTMLInputElement>
onWheelCaptureWheelEventHandler<HTMLInputElement>
openboolean
optimumnumber
patternstring
placeholderstring
playsInlineboolean
posterstring
prefixstring
preloadstring
propertystring
radioGroupstring
readOnlyboolean
relstring
requiredboolean
resourcestring
resultsnumber
revstring
reversedboolean
roleAriaRole
rowsnumber
rowSpannumber
sandboxstring
scopestring
scopedboolean
scrollingstring
seamlessboolean
securitystring
selectedboolean
shapestring
sizenumber
sizesstring
slotstring
spannumber
spellCheckBooleanish
srcstring
srcDocstring
srcLangstring
srcSetstring
startnumber
stepstring | number
styleCSSProperties
summarystring
suppressContentEditableWarningboolean
suppressHydrationWarningboolean
tabIndexnumber
targetstring
titlestring
tooltipClassesstring
translate"yes" | "no"
typestring
typeofstring
unselectable"off" | "on"
useMapstring
validboolean
validate(value: any) => boolean
validateOnChangeboolean
validateOnMountboolean
valuestring
vocabstring
widthstring | number
wmodestring
wrapstring
wrapperRefMutableRefObject<HTMLDivElement>
"aria-dropeffect"deprecated"none" | "link" | "copy" | "execute" | "move" | "popup"
in ARIA 1.1
Indicates what functions can be performed when a dragged object is released on the drop target.
"aria-grabbed"deprecatedBooleanish
in ARIA 1.1
Indicates an element's "grabbed" state in a drag-and-drop operation.
onKeyPressdeprecatedKeyboardEventHandler<HTMLInputElement>
onKeyPressCapturedeprecatedKeyboardEventHandler<HTMLInputElement>

Examples

Connected to the PlasmaState
1
import {CheckboxConnected, Label} from '@coveord/plasma-react';
2
3
const Demo = () => (
4
<CheckboxConnected>
5
<Label>Label</Label>
6
</CheckboxConnected>
7
);
8
export default Demo;
Disabled
1
import {Checkbox, Label} from '@coveord/plasma-react';
2
3
const Demo = () => (
4
<Checkbox disabled>
5
<Label>Label</Label>
6
</Checkbox>
7
);
8
export default Demo;
A group of checkboxes
1
import {GroupableCheckboxConnected, Label} from '@coveord/plasma-react';
2
3
const Demo = () => (
4
<>
5
<GroupableCheckboxConnected id="parent-id" isParent clearSides classes="mb1">
6
<Label>Parent</Label>
7
</GroupableCheckboxConnected>
8
<GroupableCheckboxConnected id="child-1-id" parentId="parent-id">
9
<Label>Child 1</Label>
10
</GroupableCheckboxConnected>
11
<GroupableCheckboxConnected id="child-2-id" parentId="parent-id">
12
<Label>Child 2</Label>
13
</GroupableCheckboxConnected>
14
<GroupableCheckboxConnected id="child-3-id" parentId="parent-id">
15
<Label>Child 3</Label>
16
</GroupableCheckboxConnected>
17
</>
18
);
19
export default Demo;

Best Practices

Use checkboxes so that users can select one or more options from a list, or none at all.

Use a stand-alone checkbox to toggle a single option on/off if the result is not immediately visible, e.g., when a final confirmation from the user is required to apply changes.

Conversely, if the result is applied immediately, such as a change of display, use a Toggle instead.

Aim for seven or less options. If that's impossible, consider breaking your set of options into several smaller logical sets or consider using Multi select instead.

List options in alphanumerical order unless a more suited ordering rationale applies, for example when listing size or security level options. If no rationale stands out, place options in alphanumerical order.

Labeling

Keep titles and labels short, preferably under three words.

Title

Always use a title when offering multiple options.

Provide a descriptive title without action verbs. For example, write "Grocery items" rather than "Select all grocery items".

For a stand-alone checkbox, the title is optional. Use a title only if you need to dissociate the stand-alone checkbox from other adjacent checkboxes.

Labels

Labels identify each option and should be self-explanatory.

Use a consistent writing style for all options in the list.

For a stand-alone checkbox, use a positive and active wording that clearly indicates what happens if the checkbox is selected. For example, write "Send me a text notification" rather than "Email notification".

Help Text and Instructions

Instructions provide more context on the outcome of the choice to make. Use it sparingly, only when it is critical to the user's understanding.

Feedback and Validation

If there is a maximum number of options that users can select, indicate it in a description.

If an option is recommended or the default, indicate it in its label.

The partially selected state is only allowed with checkboxes that have children options. A partially selected parent checkbox indicates that only some of its children options are selected.

Related Components

If your use case doesn't match the guidelines above, consider using one of the following components instead:

  • Multi select - When there are more than seven options.
  • Toggle - When the result applies immediately, for example with a change of display.
  • Radio button - When options are mutually exclusive.
Edit guidelines