Checkbox
Component
Let the user select one or more options.
Related components: Dropdown, Form item, RadioComponent
<form>
<GoAFormItem label="Basic">
<GoACheckbox name="item" text="Item" value="" onChange={onChange}></GoACheckbox>
</GoAFormItem>
</form>
Properties
name
string
Unique name to identify the checkbox.
checked
boolean
Marks the checkbox item as selected.
text
string
Label shown beside the checkbox.
value
string
The value binding.
description
string | ReactNode
Additional content shown below the label.
disabled
boolean
Disable this control. It will not receive focus or events. Use [attr.disabled] with [formControl]. Defaults to
false
.error
boolean
Shows an error on the checkbox item. Defaults to
false
.ariaLabel
string
Defines how the text will be translated for the screen reader. If not specified it will fall back to the name.
onChange
(name: string, checked: boolean, value: string) => void
Callback function when checkbox value is changed.
maxWidth
string
Sets the maximum width of the checkbox.
testId
string
Sets the data-testid attribute. Used with ByTestId queries in tests.
mt,mr,mb,ml
Spacing (none | 3xs | 2xs | xs | s | m | l | xl | 2xl | 3xl | 4xl)
Apply margin to the top, right, bottom, and/or left of the component.
Examples
Use tags in the description
Help text with a link.
<GoAFormItem label="Select one or more options">
<GoACheckbox
checked={true}
name="optionOne"
text="Option one"
description={<span>Help text with a <a href="#">link</a>.</span>}
/>
<GoACheckbox checked={false} name="optionTwo" text="Option two" />
<GoACheckbox checked={false} name="optionThree" text="Option three" />
</GoAFormItem>
Book time in drop in hours