Forms & inputs
Layout
RadioGroup
A group of Radio options where only one can be selected at a time. Use it for a short list of choices that should all stay visible.
Validating a form? vael-form wires this up with a schemaInstall
import { RadioGroup } from 'vael-ui'Playground
vertical
Placement, behaviour and animation
Usage
<script setup lang="ts">
import { ref } from 'vue'
import { RadioGroup, Radio } from 'vael-ui'
const value = ref<string | number | null>(null)
</script>
<template>
<RadioGroup v-model="value">
<Radio value="standard" label="Standard shipping" />
<Radio value="express" label="Express shipping" />
<Radio value="overnight" label="Overnight shipping" disabled />
</RadioGroup>
</template>Motion New
RadioGroup: its appearance; its radios keep their own motion.
<RadioGroup
:motion="{ initial: { root: { opacity: 0, y: 4 } } }"
/>| Name | Type | Description |
|---|---|---|
initialexit | root | 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. |
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 Radio Group pattern from the WAI-ARIA Authoring Practices Guide.
| Key | Action |
|---|---|
| Tab | Moves focus into the group, onto the selected radio. |
| ArrowDownArrowRight | Selects the next radio. |
| ArrowUpArrowLeft | Selects the previous radio. |
| Space | Selects the focused radio. |
- A
divwithrole="radiogroup"around native radios that share onename, so the browser handles the arrow keys. - Inside a
Field, the label names the group witharia-labelledby, and the description and error are linked witharia-describedby. Outside one, give it anaria-label. - It sets
aria-invalidandaria-requiredfrom theField.