vael-ui v0.5.7

Forms & inputs

Layout

Radio

One option in a set where only one can be selected. Use it only inside a RadioGroup.

Validating a form? vael-form wires this up with a schema

Install

import { Radio } from 'vael-ui'

Playground

Usage
<script setup lang="ts">
import { Radio } from 'vael-ui'
</script>

<template>
  <Radio aria-label="Standard shipping" value="playground-option" />
</template>

Props

NameTypeDefaultDescription
valueRequiredstring | numberValue the parent RadioGroup's model takes when this radio is selected.
labelstringLabel text; the default slot replaces it.
disabledbooleanDisables this radio. The parent RadioGroup's disabled also disables it.
descriptionstringSecondary line under the label.
motionRadioMotiontrueHow it moves: its appearance ({ initial: { control: { opacity: 0, scale: 0.8 } } }) and its states, like checked or invalid ({ states: { checked: { control: { scale: '1.1' } } } }). false turns its own animation off, built-in transitions too; animate the exposed controlEl/dotEl yourself.
uiPartial<Record<'root' | 'control' | 'label' | 'description', UiPartValue>>Class and style overrides for each part.

Events

No events.

Slots

NameTypeDescription
default{ checked: boolean; }Label content; replaces the label text. Receives checked.

Exposed

NameTypeDescription
elHTMLElement | nullRoot element.
inputElHTMLInputElement | nullNative radio input.
controlElHTMLElement | nullThe circle that fills when selected.
dotElHTMLElement | nullThe dot inside it.
partsRecord<string, HTMLElement | HTMLElement[] | null>Its elements by part name, for your own animation; a repeated part is an array.

Motion New

Radio: its appearance and states.

<Radio
  :motion="{ states: { checked: { root: { scale: 1.04 } } } }"
/>
NameTypeDescription
initialexitrootcontrollabeldescriptionSets 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.
statescheckeduncheckedinvaliddisabledfocusactivehoverSets 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) => animationAnimates 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 | stringTimes all of it: a spring, or a duration in ms with an easing. Never both.
falsebooleanTurns 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.

KeyAction
SpaceSelects the focused radio.
  • A native radio inside a <label>; the label prop or default slot names it, and description is read as part of that name.
  • It must sit inside a RadioGroup, which shares one name across its radios. The arrow keys come from the group.
  • id and aria-* attributes you pass go to the input.