Skip to content

Checkbox

A control that allows the user to toggle between checked and not checked.

Examples

Default

vue
<script setup>
import { Checkbox } from '@empathyds/vue'
</script>

<div class="flex items-center space-x-2">
  <Checkbox id="terms" />
  <label
    for="terms"
    class="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
  >
    Accept terms and conditions
  </label>
</div>

Props

Checkbox

PropTypeDefaultDescription
checkedboolean | 'indeterminate'-The controlled checked state of the checkbox.
defaultCheckedboolean | 'indeterminate'-The checked state of the checkbox when it is initially rendered.
disabledbooleanfalseWhen true, prevents the user from interacting with the checkbox.
requiredbooleanfalseWhen true, indicates that the user must check the checkbox before the owning form can be submitted.
namestring-The name of the checkbox. Submitted with its owning form as part of a name/value pair.
valuestring'on'The value given as data when submitted with a name.
idstring-A unique identifier for the checkbox.

Events

Checkbox

EventPayloadDescription
update:checkedbooleanEvent handler called when the checked state of the checkbox changes.