Forms & inputs
Layout
Checkbox
A box for one yes or no choice, with an optional indeterminate state. Use it when each choice is independent of the others.
Validating a form? vael-form wires this up with a schemaInstall
import { Checkbox } from 'vael-ui'Playground
undefined
Placement, behaviour and animation
Usage
<script setup lang="ts">
import { ref } from 'vue'
import { Checkbox } from 'vael-ui'
const value = ref(false)
</script>
<template>
<Checkbox label="Checkbox label" v-model="value" />
</template>Motion New
Checkbox: its appearance and states.
<Checkbox
:motion="{ states: { checked: { root: { scale: 1.04 } } } }"
/>| Name | Type | Description |
|---|---|---|
initialexit | rootcontrolindicatorlabel | Sets where each part comes in from and leaves to: any CSS property, plus x, y and blur. A plain number is px, or degrees for rotate. |
states | checkeduncheckedindeterminateinvaliddisabledfocusactivehover | Sets values per part that hold while a state is on. An array is a set of keyframes that plays once as the state turns on, such as a shake on invalid. |
enterleave | (parts, context) => animation | Animates the parts with GSAP, motion or element.animate(). Return the animation and the component waits for it, and stops it if interrupted. |
springdurationeasing | { damping, response } | number | string | Times all of it: a spring, or a duration in ms with an easing. Never both. |
false | boolean | Turns its motion off, for an animation of your own on its exposed elements. |
Accessibility
Follows the Checkbox pattern from the WAI-ARIA Authoring Practices Guide.
| Key | Action |
|---|---|
| Space | Checks or unchecks it. |
- A native checkbox inside a
<label>, so thelabelprop or the default slot names it. indeterminatesets the native mixed state, which screen readers announce.- Inside a
Field, the description and error are linked witharia-describedby, and it setsaria-invalidandaria-required. idandaria-*attributes you pass go to the input.