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.
<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:
import '@astryx-vue/themes/neutral.css'Anatomy
| Element | Description |
|---|---|
| Checkbox | The check box itself: unchecked, checked, or indeterminate. |
| Label | Text describing what the checkbox controls. Always present for accessibility. |
| Description | Helper text below the label with additional context. |
| Status message | An error, warning, or success message below the checkbox. |
Best practices #
| Guidance | Practices |
|---|---|
| Do | Always provide a visible label so the user knows what they are toggling. Use isLabelHidden only when surrounding context makes it obvious. |
| Do | Add a description for choices that need extra context, like explaining what "Share usage data" actually shares. |
| Do | Use the indeterminate state for "select all" checkboxes when only some items in a group are selected. |
| Don't | Use a checkbox for mutually exclusive choices; use RadioList when only one option can be selected. |
| Don't | Use a checkbox for actions that take effect immediately; use a toggle switch or button instead. |
| Don't | Wrap 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
Checked, unchecked, disabled, and indeterminate, each with a description.
Checkbox Input — Indeterminate
Select all shows a dash when only some notifications are on.
Checkbox Input — Status
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.isLabelHiddenonly hides the visual label, and the label text still provides the accessible name. aria-describedbyreferences the description and the status message, so both are announced on focus.- The mixed state comes from the native
indeterminateproperty, which browsers and assistive technology recognise directly. isRequiredenables 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.