Actions
Layout
SelectButton
A segmented control that picks one or more values from a short list. Use it instead of radios or checkboxes when every option fits in one row.
Install
import { SelectButton } from 'vael-ui'Playground
Fruits
undefined
Placement, behaviour and animation
Usage
<script setup lang="ts">
import { ref } from 'vue'
import { SelectButton } from 'vael-ui'
const items = [
{ label: 'Apple', value: 'apple' },
{ label: 'Banana', value: 'banana' },
{ label: 'Cherry', value: 'cherry' },
]
const value = ref<string | number | (string | number)[] | null>(null)
</script>
<template>
<SelectButton :items="items" v-model="value" />
</template>Motion New
SelectButton: its appearance, and how the selection moves.
<SelectButton
:motion="{ states: { disabled: { root: { scale: 1.04 } } } }"
/>| Name | Type | Description |
|---|---|---|
initialexit | rootoptionindicator | 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 | disabled | 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. |
move | (parts, context) => animation | Moves its sliding indicator. A spring retimes it, and a move hook animates it with your own library, starting from context.from. |
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 and out of it. |
| ArrowRightArrowDownArrowLeftArrowUp | Moves to and selects the next or previous option (single choice). |
| Space | Selects the focused option, or toggles it with multiple. |
- Built on native inputs: radios inside
role="radiogroup", or checkboxes insiderole="group"withmultiple. The browser handles the keys. - Give the group a name: wrap it in a Field, or pass
aria-label. A Field also setsaria-invalidandaria-requiredon it. - Each option’s
labelis its accessible name. The sliding highlight isaria-hidden.