An implementation of a checkbox as a form-connected web-component.
Used anywhere an author might otherwise use an input[type="checkbox"]
- form association
- focus delegation
We want general feature-parity between this component and an input[type="checkbox"]
. Most of these concerns are addressed by microsoft#2723, but some stateful nuance will need to be handled by this component.
- FAST Checkbox (React)
- Material UI
- Lightning Design
- Carbon Design
- Ant Design
- Atlassian
- Office Fabric
- Windows (UWP)
Extends form associated custom element.
Component Name
fast-checkbox
IDL attributes
defaultChecked: boolean
- If the checkbox is checked by default. Synchronized with the
checked
content attribute
- If the checkbox is checked by default. Synchronized with the
checked: boolean
- The current checked state of the checkbox
indeterminate: boolean
- The indeterminate state. Independent of checked
Content attributes
readonly
- The checkbox should be submitted with the form but should not be editable.
value
- Defaults to "on" to match
input[type="checkbox"]
- Defaults to "on" to match
checked
- The initial checked value.
Events
change: CustomEvent
- no custom data
- bubbles
<!-- shadow root -->
<label part="label"><slot></slot></label>
<div part="checkbox">
<div part="checked-indicator"></div>
<div part="indeterminate-indicator"></div>
</div>
<!-- end shadow root -->
Slot Names
- default: label for the checkbox
Host Classes
- checked
- disabled
- required
- readonly
Slotted Content/Slotted Classes CSS Parts
- checkbox
- label
- checked-indicator
- indeterminate-indicator
checked: true
or false
The checked state can be toggled by:
- Clicking the checkbox (or any of it's labels)
- Pressing the space-bar while focus is placed on the checkbox
- Adding / removing the "checked" content attribute
- This will only trigger a change if the "checked" property has not been changed, either through user action or programmatically
disabled: true
or false
When disabled, the value will not be changeable through user interaction. It should also not expose it's value to a form submission.
readonly: true
or false
When readonly, the value will not be changeable through user interaction. The value will still be exposed to forms on submission.
The root element inside the shadow-dom of the checkbox will be a focusable element with the following accessability content attributes:
- role: checkbox
- aria-checked: the checked state of the component
- aria-required: the required state of the component
- aria-disabled: the disabled state of the component
- tabindex: 0
Because we're delegating focus to this element, the relevant information will be presented to AT users when they focus this element.
N/A
N/A
N/A
N/A
N/A
N/A
N/A
N/A
Adding mechanisms, slots, and data for surfacing validation error messages.