vael-ui v0.5.7

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

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>

Props

NameTypeDefaultDescription
itemsRequiredreadonly T[]Actions to fan out, one icon button each.
direction'right' | 'left' | 'up' | 'down' | 'quarter-circle''up'Which way the actions fan out from the trigger, on screen: 'left' is left on a right-to-left page too. 'quarter-circle' lays them on an arc of radius.
openOn'hover' | 'click''click'What opens the dial. 'hover' only responds to hover-capable pointers; click always works too.
disabledbooleanfalseDisables the trigger and blocks interaction.
closeOnSelectbooleantrueCloses the dial when you select an action; false keeps it open.
ariaLabelstring'Actions'Accessible name for both the trigger button and the action role="menu".
radiusnumber96Arc radius in pixels. Only applies when direction is 'quarter-circle'.
motionSpeedDialMotiontrueHow the actions fan out and back, and the icon turns. false shows them and turns the icon at once. An object animates the actions your way: values for the action part, stagger, or enter / leave hooks for your own library.
uiPartial<Record<'root' | 'trigger' | 'action' | 'icon', UiPartValue>>Class and style overrides for each part.
openbooleanfalseWhether the actions are shown.

Events

NameTypeDescription
select(item: T)Fires when you click an action.
update:open(value: boolean)Fires when open changes (v-model:open).

Slots

NameTypeDescription
icon{ open: boolean; }Replaces the trigger's plus icon.
item{ item: T; index: number; }Custom content for each action button. Unset, the button shows the item's icon.

Exposed

NameTypeDescription
elHTMLElement | nullRoot element.
listElHTMLElement | nullAction list element (role="menu").
iconElHTMLElement | nullTrigger icon wrapper. Turns 45deg while open.
open() => voidShows the actions. No-op while disabled.
close() => voidHides the actions.
toggle() => voidShows or hides the actions. No-op while disabled.

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 }"
/>
NameTypeDescription
initialexitactionSets 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) => animationAnimates the parts with GSAP, motion or element.animate(). Return the animation and the component waits for it, and stops it if interrupted.
staggerleavingappearnumber | 'pop' | 'hold' | booleanItems 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 | 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

KeyAction
EnterSpaceOpens or closes the dial from the trigger, or runs the focused action.
ArrowUpArrowDownArrowLeftArrowRightMoves between actions along the direction they fan out in, wrapping at the ends.
HomeEndMoves to the first or last action.
A letterMoves to the next action whose label starts with the typed letters.
EscapeCloses the dial, and focuses the trigger if focus was inside it.
  • The trigger is a native <button> with aria-haspopup="menu", aria-expanded, aria-controls while open, and aria-label (a translated “Actions” by default). While open, the actions sit in role="menu" as menuitem buttons named by each item’s label.
  • 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 direction up, ArrowUp moves away from the trigger; left and right use the horizontal arrows. The directions are physical, so the arrow keys don’t swap right to left.