Actions
Layout
ButtonGroup
A connected row or column of buttons that can also work as single or multiple toggles. Use it for related actions or options that belong together.
Install
import { ButtonGroup } from 'vael-ui'Playground
horizontal
Placement, behaviour and animation
Usage
<script setup lang="ts">
import { ref } from 'vue'
import { ButtonGroup, Button } from 'vael-ui'
const value = ref<ButtonGroupValue | readonly ButtonGroupValue[] | null>()
</script>
<template>
<ButtonGroup v-model="value">
<Button variant="outline">Archive</Button>
<Button variant="outline">Report</Button>
<Button variant="outline">Snooze</Button>
</ButtonGroup>
</template>Motion New
ButtonGroup: its appearance; its buttons keep their own motion.
<ButtonGroup
: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
| Key | Action |
|---|---|
| TabShiftTab | Moves between the buttons; each one is its own Tab stop. |
| EnterSpace | Runs or toggles the focused button. |
- Renders
role="group". Passaria-labelto name the group. - With
v-model, every Button inside that has avaluebecomes a toggle and getsaria-pressed. Without it, the group only joins the buttons visually.