WlCheckbox
States
Full example
<script setup lang="ts">
import { WlCheckbox } from "legato-ui";
import { ref } from "vue";
const value = ref(true);
const permissions = ref<number[]>([1]);
</script>
<template>
<div class="wl-stack" data-space="md">
<WlCheckbox v-model="value" >{{ "Receive updates" }}</WlCheckbox>
<fieldset class="wl-choice-group">
<legend class="wl-choice-group__legend wl-text-label">{{ "Permissions" }}</legend>
<div class="wl-surface wl-stack" data-space="sm">
<WlCheckbox v-model="permissions" :value="1" size="sm">{{ "Read" }}</WlCheckbox>
<WlCheckbox v-model="permissions" :value="2" size="sm">{{ "Share" }}</WlCheckbox>
<output class="wl-text-small wl-text-muted" aria-label="Permissions">
<code>{{ JSON.stringify(permissions) }}</code>
</output>
</div>
</fieldset>
</div>
</template>Size and density
Full example
<script setup lang="ts">
import { WlCheckbox } from "legato-ui";
import { ref } from "vue";
const value = ref(true);
const permissions = ref<number[]>([1]);
</script>
<template>
<div class="wl-stack" data-space="md">
<WlCheckbox v-model="value" >{{ "Receive updates" }}</WlCheckbox>
<fieldset class="wl-choice-group">
<legend class="wl-choice-group__legend wl-text-label">{{ "Permissions" }}</legend>
<div class="wl-surface wl-stack" data-space="sm">
<WlCheckbox v-model="permissions" :value="1" size="sm">{{ "Read" }}</WlCheckbox>
<WlCheckbox v-model="permissions" :value="2" size="sm">{{ "Share" }}</WlCheckbox>
<output class="wl-text-small wl-text-muted" aria-label="Permissions">
<code>{{ JSON.stringify(permissions) }}</code>
</output>
</div>
</fieldset>
</div>
</template>Related checkboxes
Select all available items with calculated indeterminate, consent with an error and disabled.
Linked selection and indeterminate
The application computes the intermediate state when some child items are selected. Space toggles the focused checkbox.
Label, error and disabled
Notifications selected: 1 of 2. Agreement: not confirmed.
Full example
<script setup lang="ts">
import { WlButton, WlCheckbox, WlField } from "legato-ui";
import { computed, ref } from "vue";
const notifications = ref([{ id: "mail", label: "Email", enabled: true }, { id: "push", label: "Push notifications", enabled: false }]);
const selectedCount = computed(() => notifications.value.filter((item) => item.enabled).length);
const allSelected = computed({
get: () => selectedCount.value === notifications.value.length,
set: (checked: boolean) => {
notifications.value.forEach((item) => {
item.enabled = checked;
});
}
});
const mixed = computed(() => selectedCount.value > 0 && !allSelected.value);
const consent = ref(false);
const permissions = ref<number[]>([1]);
const summary = computed(() =>
"Notifications selected:" + " " + selectedCount.value + " " + "of" + " "
+ notifications.value.length + ". Agreement:" + " "
+ (consent.value ? "confirmed" : "not confirmed") + "."
);
</script>
<template>
<div class="wl-stack" data-space="xl" data-input-example="WlCheckbox">
<fieldset class="wl-choice-group">
<legend class="wl-choice-group__legend wl-text-label">{{ "Permissions" }}</legend>
<div class="wl-surface wl-stack" data-space="sm">
<WlCheckbox v-model="permissions" :value="1" size="sm">{{ "Read" }}</WlCheckbox>
<WlCheckbox v-model="permissions" :value="2" size="sm">{{ "Share" }}</WlCheckbox>
<output class="wl-text-small wl-text-muted" aria-label="Permissions">
<code>{{ JSON.stringify(permissions) }}</code>
</output>
</div>
</fieldset>
<section class="wl-stack" data-space="md">
<h3 class="wl-text-subheading">{{ "Linked selection and indeterminate" }}</h3>
<WlCheckbox v-model="allSelected" :indeterminate="mixed">{{ "All available notifications" }}</WlCheckbox>
<div class="wl-stack" data-space="sm">
<WlCheckbox v-for="item in notifications" :key="item.id" v-model="item.enabled">{{ item.label }}</WlCheckbox>
</div>
<p class="wl-text-small wl-text-muted">{{ "The application computes the intermediate state when some child items are selected. Space toggles the focused checkbox." }}</p>
</section>
<section class="wl-stack" data-space="md">
<h3 class="wl-text-subheading">{{ "Label, error and disabled" }}</h3>
<WlField
id="docs-checkbox-consent"
v-slot="{ id, ariaDescribedby, invalid }"
:error="consent ? undefined : 'Confirm your agreement.'"
><WlCheckbox
:id="id"
v-model="consent"
:invalid="invalid"
:aria-describedby="ariaDescribedby"
required
>{{ "I agree to the terms" }}</WlCheckbox></WlField>
<WlCheckbox :model-value="true" disabled>{{ "System notifications are required" }}</WlCheckbox>
<WlButton size="sm" @click="allSelected = false; consent = false">{{ "Clear available checkboxes" }}</WlButton>
<p class="wl-text-small" role="status">{{ summary }}</p>
</section>
</div>
</template>Props
Types, accepted values and literal defaults come from the public manifest. Inherited settings name their source; “Not set” means no default is declared.
v-model: Value extends undefined ? boolean : Value[]Whether checked (default false).
| Prop | Type / values | Default | Purpose |
|---|---|---|---|
disabled | boolean | false | Disables the checkbox. |
indeterminate | boolean | false | Indeterminate state. |
invalid | boolean | false | Error state. |
pt | WlPt< | Not set | Attributes of internal Legato UI elements. |
value | Value | Not set | Value associated with this choice in the group model. |
size | WlSwitchSize | "md" | Size within the component family's documented scale. |
density | WlDensity | "default" | Spacing density for this component family. |
Events
| Event | Payload | When emitted |
|---|---|---|
update:modelValue | Value extends undefined ? boolean : Value[] | Emitted when the component requests a model change; the payload is the next value. |
Slots
| Slot | Type / values | Content |
|---|---|---|
default | — | Label next to the checkbox. |
Pass-through: pt
Sections WlCheckbox are listed below. Attributes merge in this order: createWlPt() WlConfig.ptpt instance. Class and style merge; the last supplied value takes priority for other attributes.
| Section | DOM | Purpose |
|---|---|---|
box | span.wl-checkbox__box | The box section in WlConfig.pt.checkbox configuration. |
icon | span.wl-checkbox__icon | The icon section in WlConfig.pt.checkbox configuration. |
input | input | The input section in WlConfig.pt.checkbox configuration. |
Sections refer to the component DOM. Dotted names identify a configuration group and its section; composite parts use their own pt groups. Global and local attributes merge, with class and style added together.
Keyboard and accessibility
- Default slot text becomes part of the native label. An option without text must have an accessible name.
- Space toggles the native checkbox. The model is boolean; indeterminate is a separate state calculated by the application.
- For “select all”, calculate the mixed state from available child items. Do not select disabled items through a hidden action.
- For a consent error, pass invalid and associate an explanation through aria-describedby; required and disabled retain native semantics.
Keyboard and application responsibilities
| Key | Action |
|---|---|
| Tab / Shift+Tab | Focus an enabled native control. |
| Space | Change the current choice. |
Provide a meaningful accessible name and connect labels, hints and errors to the focusable element. Check the behavior with your own data and a screen reader.
WAI-ARIA Authoring PracticesChanges are emitted through v-model. After selection, cancellation and reset, labels and states must remain clear.
In your application, check keyboard controls, zoom and focus visibility. State labels and required information must be readable in every theme.