Checkbox Input

Alignment target:@astryxdesign/core v0.7.1 · CheckboxInput

Usage #

Use CheckboxInput for a boolean option or a list of independent choices. The component includes a label, description and status message.

Vue
<script setup lang="ts">
import { CheckboxInput } from '@astryx-vue/core/CheckboxInput'
import { shallowRef } from 'vue'

const selected = shallowRef(false)
</script>

<template>
  <CheckboxInput v-model="selected" label="Email updates" />
</template>

Import the theme once in the application entry:

TypeScript
import '@astryx-vue/themes/neutral.css'

Anatomy

ElementDescription
CheckboxThe check box itself: unchecked, checked, or indeterminate.
LabelText describing what the checkbox controls. Always present for accessibility.
DescriptionHelper text below the label with additional context.
Status messageAn error, warning, or success message below the checkbox.

Best practices #

GuidancePractices
DoAlways provide a visible label so the user knows what they are toggling. Use isLabelHidden only when surrounding context makes it obvious.
DoAdd a description for choices that need extra context, like explaining what "Share usage data" actually shares.
DoUse the indeterminate state for "select all" checkboxes when only some items in a group are selected.
Don'tUse a checkbox for mutually exclusive choices; use RadioList when only one option can be selected.
Don'tUse a checkbox for actions that take effect immediately; use a toggle switch or button instead.
Don'tWrap a disabled checkbox in Tooltip to explain why it is disabled; disabled controls swallow the hover events the wrapper needs. Use the disabledMessage prop instead.

Examples #

Checkbox Input — States

This checkbox is currently on.
This checkbox is currently off.
This checkbox cannot be changed.
This checkbox represents a partial selection.
Open in Playground

Checked, unchecked, disabled, and indeterminate, each with a description.

Checkbox Input — Indeterminate

2 of 4 enabled
Open in Playground

Select all shows a dash when only some notifications are on.

Checkbox Input — Status

Required field that has not been accepted.
You must accept the terms to continue
Enabled setting with a side effect to be aware of.
This data may be shared with partners
Confirmed setting that has been verified.
Your email has been verified
Open in Playground

Error, warning, and success messages under the checkbox.

Keyboard and accessibility #

CheckboxInput renders a native <input type="checkbox">, so keyboard behaviour follows the browser defaults: press Tab to focus the checkbox, and press Space to toggle the selection.

The component wires the label, description and status message together through ARIA attributes, so assistive technology reads them as one unit:

  • Always provide label; screen readers use it to describe what this option means. isLabelHidden only hides the visual label, and the label text still provides the accessible name.
  • aria-describedby references the description and the status message, so both are announced on focus.
  • The mixed state comes from the native indeterminate property, which browsers and assistive technology recognise directly.
  • isRequired enables the browser's native required validation.
  • When the status is an error, the component sets aria-invalid.

For a decorative selection mark on its own, use CheckboxIndicator.