Back to Fluentui

Checkbox

packages/web-components/src/checkbox/README.md

4.40.2-hotfix25.1 KB
Original Source

Checkbox

An implementation of a checkbox as a form-connected web-component.

Design Spec

Link to Checkbox Design Spec in Figma

Engineering Spec

Fluent WC3 Checkbox extends from the FAST Checkbox and is intended to be as close to the Fluent UI React 9 Checkbox implementation as possible. However, due to the nature of web components there will not be 100% parity between the two.

Class: Checkbox

Component Name

<fluent-checkbox>

Component Template

FAST checkboxTemplate

Variables

NameDescriptionType
CheckboxLabelPositionlabel position types{ before: "before", after: "after" }
CheckboxShapecheckbox shape types{ square: "square", circular: "circular" }
CheckboxSizecheckbox size types{ medium: "medium", large: "large" }

Methods

NamePrivacyDescription
keypressHandlerpublicfires on keyboard press
clickHandler publicfires on mouse click

Events

NameTypeDescriptionInherited From
changeFires a custom change eventFASTCheckbox

Attributes

NamePrivacyTypeDefaultDescription
label-positionpublicCheckboxLabelPositionCheckboxLabelPosition.afterIndicates postion of label
checkedpublicbooleanfalseIndicates whether input is checked
indeterminatepublicbooleanfalseIndicates whether input is initially indeterminate
disabledpublicbooleanfalseIndicates whether input is disabled
required publicbooleanfalseIndicates whether input is required
sizepublicCheckboxSizeCheckboxSize.mediumIndicates the size of the checkbox
shapepublicCheckboxShapeCheckboxShape.squareIndicates shape of the checkbox

IDL Attributes

NameFieldTypeDescription
checkedcheckedbooleanThe current checked state of the checkbox
indeterminateindeterminatebooleanThe indeterminate state. Independent of checked

Slots

NameDescription
The default slot for text input content
checked-indicatorThe named slot for the checked indicator
indeterminate-indicatorThe named slot for the indeterminate indicator
<hr />

Accessibility

W3C Checkbox Spec

WAI-ARIA Roles, States, and Properties

  • role="checkbox"
  • aria-checked
  • aria-required
  • aria-disabled

Fluent Web Component v3 v.s Fluent React 9

Component and Slot Mapping

Fluent UI React 9Fluent Web Components 3Description
<Checkbox><fluent-checkbox>
n/aslot: checked-indicatorslot for checked indicator
n/aslot: indeterminate-indicatorslot for indeterminate indicator

Property Mapping

Fluent UI React 9Fluent Web Components 3Description of difference
`checked: boolean'mixed'`checked: boolean indeterminate: boolean