--- url: "https://web.dev/articles/components-howto-checkbox" titulek: "HowTo Components – howto-checkbox | Articles | web.dev" h1: "HowTo Components – howto-checkbox Stay organized with collections Save and categorize content based on your preferences." popis: "" jazyk: "en" kanonicka: "https://web.dev/articles/components-howto-checkbox" drobecky: ["Articles", "HowTo Components – howto-checkbox"] zdroj: "live" wayback_snapshot: "" stazeno: "2026-09-13 22:27:36" znaku: 7989 slov: 1016 kodovani: "iso-8859-2" sha256: "afc1424a16c201890f1c5af933098ee74d54a9c12b39ba2d0302e4641392cd61" --- HowTo Components – howto-checkbox Stay organized with collections Save and categorize content based on your preferences. Ewa Gasperowicz Rob Dodson Surma Summary A `` represents a boolean option in a form. The most common type of checkbox is a dual-type which allows the user to toggle between two choices -- checked and unchecked. The element attempts to self apply the attributes `role="checkbox"` and `tabindex="0"` when it is first created. The `role` attribute helps assistive technology like a screen reader tell the user what kind of control this is. The `tabindex` attribute opts the element into the tab order, making it keyboard focusable and operable. To learn more about these two topics, check out [What can ARIA do?](/semantics-aria#what-can-aria-do) and [Using tabindex](/using-tabindex). When the checkbox is checked, it adds a `checked` boolean attribute, and sets a corresponding `checked` property to `true`. In addition, the element sets an `aria-checked` attribute to either `"true"` or `"false"`, depending on its state. Clicking on the checkbox with a mouse, or space bar, toggles these checked states. The checkbox also supports a `disabled` state. If either the `disabled` property is set to true or the `disabled` attribute is applied, the checkbox sets `aria-disabled="true"`, removes the `tabindex` attribute, and returns focus to the document if the checkbox is the current `activeElement`. The checkbox is paired with a `howto-label` element to ensure it has an [accessible name](https://developers.google.com/web/fundamentals/accessibility/semantics-builtin/the-accessibility-tree#semantics_in_native_html). Reference [HowTo: Components on GitHub](https://github.com/GoogleChromeLabs/howto-components) [Checkbox Pattern in ARIA Authoring Practices 1.1](https://www.w3.org/TR/wai-aria-practices-1.1/#checkbox) [What can ARIA Do?](/semantics-aria#what-can-aria-do) [Using tabindex](/using-tabindex) Demo [View live demo on GitHub](https://googlechromelabs.github.io/howto-components/howto-checkbox/#demo) Example usage ` Join Newsletter` Code `(function() {` Define key codes to help with handling keyboard events. `const KEYCODE = { SPACE: 32, };` Cloning contents from a `