Skip to content

Checkbox

Turn an option on or off.

Demos

Size
State
Include archived projectsShow completed work in this view.

Usage

vue
<script setup lang="ts">
import { Accordion } from '~/components/ui/accordion'

const items = [
  { value: 'source', label: 'Do I own the source?', content: 'Yes. Copy and adapt the files.' },
]
</script>

<template>
  <Accordion :items="items" />
</template>

Installation

Complete the shared installation. Copy Checkbox.vue and index.ts into app/components/ui/checkbox/.

API

Variants and defaults

PropValuesDefault
sizexs, sm, md, lg, xlsm

Props

PropTypeDefaultDescription
disabledbooleanfalseDisables the checkbox.
idstringautoHTML id for the button element.
namestring—HTML name for form submission.
requiredbooleanfalseMarks the field as required.
trueValueunknowntrueModel value when checked.
falseValueunknownfalseModel value when unchecked.
labelstring—Label text. Slot #label takes priority.
descriptionstring—Description text. Slot #description takes priority.
ariaLabelstring—Accessible name when no visible label is rendered.
ariaDescribedbystring—IDs of external descriptive elements.
uiCheckboxUi—CSS class overrides.

Slots

SlotScoped propsDescription
indicator{ checked }Visual check mark inside the button. checked is true, false, or "indeterminate".
label—Label text. Defaults to the label prop.
description—Description text. Defaults to the description prop.

Events

EventPayloadDescription
value-change[value: CheckboxValue, details]Fired when the checked state changes.

Keyboard

KeyBehavior
Enter / SpaceToggles focused checkbox.
Tab / Shift + TabUses native document focus order.

Visible label is a real <label> associated with control, so pointer and touch activation on label toggles checkbox too.