Anchor Design System

Checkbox

Checkboxes allow users to select multiple items from a list of individual items, or to mark one individual item as selected.

Installation

Usage

Checked

Disabled

Indeterminate

The isIndeterminate prop sets a Checkbox to an indeterminate state, overriding its appearance and maintaining it until set to false, regardless of user interaction.

Slots

  • base: Checkbox wrapper, it handles alignment, placement, and general appearance.
  • wrapper: An inner container that includes styles for relative positioning, flex properties, overflow handling and managing hover and selected states.
  • icon: Icon within the checkbox, controlling size, visibility, and changes when checked.
  • label: The text associated with the checkbox.

Accessibility

  • Built with a native HTML <input> element.
  • Full support for browser features like form autofill.
  • Keyboard focus management and cross browser normalization.
  • Keyboard event support for Tab and Space keys.
  • Labeling support for assistive technology.
  • Indeterminate state support.

API

Properties

PropertyAttributeDescriptionTypeDefault
checkedcheckedbooleanfalse
disableddisabledDisable the checkboxbooleanfalse
iconiconstringthis.indeterminate ? 'minus' : 'check'
indeterminateindeterminateWhether or not the checkbox is indeterminate. The indeterminate state is purely visual and does not change the checked value of the checkbox.booleanfalse
namenameThis is the name for the entire checkbox groupstringundefined
uuiduuidGive this instance of checkbox a custom ID, or keep the default.stringuuidv4()
valuevalueThis is the string that is returned as a value, when the form is submittedstring'Checkbox'

Events

EventDescriptionType
toggledCustomEvent<any>

Methods

toggleCheckbox(e?: any) => Promise<void>

Parameters

NameTypeDescription
eany

Returns

Type: Promise<void>

Dependencies

Depends on

Graph

graph TD;
  anchor-checkbox --> anchor-label
  anchor-checkbox --> anchor-icon
  style anchor-checkbox fill:#f9f,stroke:#333,stroke-width:4px

On this page