WlCheckboxGroup
Change props to see the result: the example and code use the same settings. “Reset” restores the initial values.
Settings
Visible accessible name for the choice group.
Name used by the component's native form controls.
Disable user interaction with this component.
Expose a validation error state on the control.
Indicate pending work supplied by the application.
Props options, optionLabel, optionValue, optionDisabled, optionKey, orientation, variant, size, density, pt, models, handlers and slots can be edited in the SFC. See their descriptions in API.
Example
Tab visits enabled checkboxes; Space changes one option. Clearing and restoring are application actions.
Explore the live example and copy its Vue SFC into your application. Settings on the left can be combined.
Code for your application
Vue SFC · current settings
<script setup lang="ts">
import { WlButton, WlCheckboxGroup } from "legato-ui";
import { computed, ref } from "vue";
const selected = ref(["read"]);
const options = computed(() => [
{ value: "read", label: "Read" },
{ value: "write", label: "Write (unavailable)", disabled: true },
{ value: "share", label: "Share" }
]);
</script>
<template>
<div class="wl-stack" data-space="md" data-review-example="WlCheckboxGroup">
<WlCheckboxGroup
v-model="selected"
:options="options"
option-value="value"
option-disabled="disabled"
legend="Permissions"
orientation="horizontal"
:invalid="selected.length === 0"
/>
<p v-if="selected.length === 0" role="alert">{{ "Select at least one permission." }}</p>
<div class="wl-inline" data-space="sm">
<WlButton size="sm" @click="selected = []">{{ "Clear selection" }}</WlButton>
<WlButton size="sm" @click="selected = ['read']">{{ "Restore example" }}</WlButton>
</div>
<output aria-label="Permissions">{{ selected.join(", ") }}</output>
<p class="wl-text-small">{{ "Tab visits enabled checkboxes; Space changes one option. Clearing and restoring are application actions." }}</p>
</div>
</template>Grouped permissions
A labelled group of checkboxes with an array model and application-owned options.
Tab visits enabled checkboxes; Space changes one option. Clearing and restoring are application actions.
Vue SFC · additional example
<script setup lang="ts">
import { WlButton, WlCheckboxGroup } from "legato-ui";
import { computed, ref } from "vue";
const selected = ref(["read"]);
const options = computed(() => [
{ value: "read", label: "Read" },
{ value: "write", label: "Write (unavailable)", disabled: true },
{ value: "share", label: "Share" }
]);
</script>
<template>
<div class="wl-stack" data-space="md" data-review-example="WlCheckboxGroup">
<WlCheckboxGroup
v-model="selected"
:options="options"
option-value="value"
option-disabled="disabled"
legend="Permissions"
orientation="horizontal"
:invalid="selected.length === 0"
/>
<p v-if="selected.length === 0" role="alert">{{ "Select at least one permission." }}</p>
<div class="wl-inline" data-space="sm">
<WlButton size="sm" @click="selected = []">{{ "Clear selection" }}</WlButton>
<WlButton size="sm" @click="selected = ['read']">{{ "Restore example" }}</WlButton>
</div>
<output aria-label="Permissions">{{ selected.join(", ") }}</output>
<p class="wl-text-small">{{ "Tab visits enabled checkboxes; Space changes one option. Clearing and restoring are application actions." }}</p>
</div>
</template>