Skip to content

Checkbox Group

Lets the user select one or more options from a visible list.

Demo

Basic

Hvad er din nationalitet?

Angiv om du er dansk, svensk eller anden nationalitet

Valgt: (ingen)

With hints

Præferencer

Error state

Nationalitet

Installation

vue
<script setup>
import { GTCheckboxGroup } from '@grundtone/vue';
</script>

In Nuxt, GTCheckboxGroup is auto-imported.

When to use

Use checkboxes when the user can select multiple values. Use when they need an overview of all choices and the list fits on mobile.

Do not use when only one value can be selected (use radio). Do not use when there are too many options (use select with multi-select).

Usage

Basic

vue
<GTCheckboxGroup
  v-model="nationalities"
  label="Nationalitet"
  help-text="Angiv alle der gælder"
  :options="[
    { value: 'dk', label: 'Dansk' },
    { value: 'se', label: 'Svensk' },
    { value: 'other', label: 'Anden nationalitet' },
  ]"
/>

With option hints

vue
<GTCheckboxGroup
  v-model="prefs"
  label="Præferencer"
  :options="[
    { value: 'news', label: 'Nyhedsbrev', hint: 'Maks én email om ugen' },
    { value: 'push', label: 'Push', hint: 'Vigtige opdateringer' },
  ]"
/>

Error state

vue
<GTCheckboxGroup
  label="Nationalitet"
  error-text="Angiv mindst én nationalitet"
  :options="[...]"
/>

Props

PropTypeDefaultDescription
modelValuestring[][]Selected values (v-model)
optionsCheckboxOption[]Available options (required)
namestringautoHTML name attribute
labelstringGroup legend
helpTextstringGroup help text
errorTextstringGroup error message
requiredbooleanfalseAt least one must be selected
disabledbooleanfalseDisable all options
idstringautoID prefix

CheckboxOption

PropertyTypeDescription
valuestringOption value
labelstringDisplay label
hintstringHelp text for this option
disabledbooleanDisable this option
contentbooleanHas collapsible content (slot #content-{value})

Events

EventPayloadDescription
update:modelValuestring[]Emitted on change

Accessibility

  • Native <input type="checkbox"> (visually hidden) with custom indicator
  • <fieldset> + <legend> for group labeling
  • Space key toggles (native browser behavior)
  • Label click toggles the option

See Checkbox (Design System) for full CSS reference.