Gestures
Layout
Dock
A macOS-style row of icons that magnify as the pointer or a finger moves over them. Use it for app-style navigation or a launcher.
Install
import { Dock } from 'vael-ui'Playground
horizontal
undefined
Usage
<script setup lang="ts">
import { Dock } from 'vael-ui'
import { PhHouse, PhChatCircle, PhStar } from '@phosphor-icons/vue'
const items = [
{ label: 'Home', icon: PhHouse, style: { color: '#2563eb' } },
{ label: 'Messages', icon: PhChatCircle, style: { color: '#16a34a' } },
{ label: 'Favorites', icon: PhStar, style: { color: '#d97706' } },
]
</script>
<template>
<Dock :range="168" :items="items" />
</template>Motion New
Dock: its appearance, item by item, and each item's states: hover, active (pressed), focus, and selected, which plays each time the item is picked (a launch hop). Its spring is the one magnification follows the pointer on, overshoot included.
<Dock
:motion="{ states: { hover: { item: { scale: 1.04 } } } }"
/>| Name | Type | Description |
|---|---|---|
initialexit | rootitem | 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 | hoveractivefocusdisabledselected | 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. |
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 Toolbar pattern from the WAI-ARIA Authoring Practices Guide.
| Key | Action |
|---|---|
| ArrowLeftArrowRight | Moves focus to the previous or next item, wrapping at the ends, when horizontal. |
| ArrowUpArrowDown | Moves focus to the previous or next item, wrapping at the ends, when vertical. |
| HomeEnd | Moves focus to the first or last enabled item. |
| EnterSpace | Selects the focused item. |
- The root has
role="toolbar", plusaria-orientation="vertical"when vertical. Give it anaria-label. - The items are one Tab stop with a roving
tabindex, which falls to the first enabled item when the active one is disabled. The arrow keys skip disabled items. - Each item is a
<button>named by itslabel, plus itsbadgewhen set, such as “Inbox, 3”. The icon and the badge arearia-hidden. - Right to left, ArrowLeft and ArrowRight swap.