WlCheckboxGroup

A labelled group of checkboxes with an array model and application-owned options.
Components / Inputs v1.0.0-rc.1

Appearance

Permissions
read

Tab visits enabled checkboxes; Space changes one option. Clearing and restoring are application actions.

Full example
<script setup lang="ts">
const props = { preview: {} as Record<string, unknown> };
import { WlButton, WlCheckboxGroup } from "legato-ui";
import { computed, ref } from "vue";
const selected = ref(["read"]);
const invalid = computed(() => Boolean(props.preview?.invalid ?? (selected.value.length === 0)));
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"
      orientation="horizontal"
      
      :options="options"
      option-value="value"
      option-disabled="disabled"
      legend="Permissions"
      :invalid="invalid"
    />
    <p v-if="invalid" 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>

States

Permissions
read

Tab visits enabled checkboxes; Space changes one option. Clearing and restoring are application actions.

Full example
<script setup lang="ts">
const props = { preview: {} as Record<string, unknown> };
import { WlButton, WlCheckboxGroup } from "legato-ui";
import { computed, ref } from "vue";
const selected = ref(["read"]);
const invalid = computed(() => Boolean(props.preview?.invalid ?? (selected.value.length === 0)));
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"
      orientation="horizontal"
      
      :options="options"
      option-value="value"
      option-disabled="disabled"
      legend="Permissions"
      :invalid="invalid"
    />
    <p v-if="invalid" 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.

Permissions
read

Tab visits enabled checkboxes; Space changes one option. Clearing and restoring are application actions.

Full 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>