Actions
Layout
SpeedDial
A floating action button that fans out into secondary actions. Use it when a screen has one main button and a few related actions.
Install
import { SpeedDial } from 'vael-ui'Playground
up
click
Placement, behaviour and animation
Usage
<script setup lang="ts">
import { SpeedDial } from 'vael-ui'
import { PhFile, PhFolder, PhUploadSimple } from '@phosphor-icons/vue'
const items = [
{ label: 'New file', icon: PhFile },
{ label: 'New folder', icon: PhFolder },
{ label: 'Upload', icon: PhUploadSimple },
]
</script>
<template>
<SpeedDial :items="items" />
</template>Motion New
SpeedDial's actions: values or hooks for action, the list's stagger and leaving.
<SpeedDial
:motion="{ initial: { action: { opacity: 0, y: 8 } }, stagger: 0.04 }"
/>| Name | Type | Description |
|---|---|---|
initialexit | action | 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. |
staggerleavingappear | number | 'pop' | 'hold' | boolean | Items coming in together start stagger seconds apart. A leaving item lifts out so the rest close the gap ('pop'), or keeps its space until it's gone ('hold'). appear: true also brings in the items already there when it mounts. |
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 |
|---|---|
| EnterSpace | Opens or closes the dial from the trigger, or runs the focused action. |
| ArrowUpArrowDownArrowLeftArrowRight | Moves between actions along the direction they fan out in, wrapping at the ends. |
| HomeEnd | Moves to the first or last action. |
| A letter | Moves to the next action whose label starts with the typed letters. |
| Escape | Closes the dial, and focuses the trigger if focus was inside it. |
- The trigger is a native
<button>witharia-haspopup="menu",aria-expanded,aria-controlswhile open, andaria-label(a translated “Actions” by default). While open, the actions sit inrole="menu"asmenuitembuttons named by each item’slabel. - Opening with a click or a key moves focus to the first action; opening on hover leaves focus where it is. Choosing an action closes the dial and returns focus to the trigger, and focus moving outside the dial closes it.
- With
directionup, ArrowUp moves away from the trigger;leftandrightuse the horizontal arrows. The directions are physical, so the arrow keys don’t swap right to left.