v1.0.11

Checkbox

Installation

Install yarn add @spark-web/checkbox
Source GitHub.com
Bundle unpkg.com

Checkboxes are used to toggle between checked and unchecked states — usually in a form. If only one option from a list is allowed to be enable, consider using a RadioButton instead.

Examples

Controlled

Checkboxes can be both controlled and uncontrolled. To control a checkbox provide the checked state with a value you control, as well as an onChange function to set the new value when the checkbox is toggled.

Size

Checkboxes are available in two sizes: small and medium.

Checkbox variations (small)
Checkbox variations (medium)

Message and tone

The message is used to communicate the status of a field, such as an error message. This will be announced on focus and can be combined with a tone to illustrate intent. The supported tones are: critical, positive and neutral.

Message and tone
Critical message
Positive message
Neutral message

Props

Checkbox

PropTypeDescription

checked?

boolean

When true, the checkbox will be checked.

children?

ReactNode: string | number | false | true | {} | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal

The checkbox label content.

data?

DataAttributeMap

Sets data attributes on the component.

disabled?

boolean

When true, the checkbox will be disabled.

Default: false

message?

string

Provide a message, informing the user about changes in state.

size?

CheckboxSize: "small" | "medium"

The size of the checkbox.

Default: "small"

tone?

"critical" | "positive" | "neutral"

Provide a tone to influence elements of the field, and its input.

Default: "neutral"

value?

string

The value of the checkbox.

The Checkbox component also extends InputHTMLAttributes props and are not listed here.

CheckboxPrimitive

PropTypeDescription

checked?

boolean

When true, the checkbox will be checked.

data?

DataAttributeMap

Sets data attributes on the component.

disabled?

boolean

When true, the checkbox will be disabled.

size?

CheckboxSize: "small" | "medium"

The size of the checkbox.

Default: "small"

value?

string

The value of the checkbox.

The CheckboxPrimitive component also extends InputHTMLAttributes props and are not listed here.

© 2023 Brighte Capital Pty Ltd