Actions
Layout
SplitButton
A main action joined to a chevron that opens related actions in a dropdown. Use it when one action is the usual choice and a few others belong beside it.
Install
import { SplitButton } from 'vael-ui'Playground
Fruits
primary
undefined
Placement, behaviour and animation
undefined
undefined
Usage
<script setup lang="ts">
import { ref } from 'vue'
import { SplitButton } from 'vael-ui'
const items = [
{ label: 'Apple', value: 'apple' },
{ label: 'Banana', value: 'banana' },
{ label: 'Cherry', value: 'cherry' },
]
const open = ref(false)
</script>
<template>
<SplitButton :loading="false" :items="items" v-model:open="open" />
</template>Motion New
Menu's motion, and ContextMenu's and SplitButton's: values or hooks for positioner and panel, and how it opens and closes. false turns it off.
<SplitButton
:motion="{
initial: { panel: { opacity: 0, y: 8, scale: 0.98 } },
spring: { damping: 0.85, response: 0.35 },
}"
/>| Name | Type | Description |
|---|---|---|
initialexit | positionerpanel | 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. |
morphlinkedexitOrder | 'trigger' | Record<string, LinkedMotion> | 'reverse' | morph: 'trigger' grows it out of the element that opened it. linked moves other elements with it, such as the page receding behind it. exitOrder: 'reverse' closes its children first. |
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 Menu Button pattern from the WAI-ARIA Authoring Practices Guide.
| Key | Action |
|---|---|
| EnterSpace | Runs the main action, or opens the menu from the arrow button. |
| ArrowDown | Opens the menu from the arrow button and focuses the first item. |
| ArrowUp | Opens the menu from the arrow button and focuses the last item. |
| ArrowDownArrowUp | Moves to the next or previous item in the menu, wrapping at the ends. |
| HomeEnd | Moves to the first or last item. |
| EnterSpace | Activates the focused item and closes the menu, unless the item has keepOpen. |
| ArrowRight | Opens the focused item’s submenu. |
| ArrowLeft | Closes the submenu and focuses its parent item. |
| A letter | Moves to the next item whose label starts with the typed letters. |
| Escape | Closes the innermost open menu and returns focus to what opened it. |
| TabShiftTab | Closes the menu and moves focus past or back to the arrow button. |
- Two native
<button>elements. The arrow button is named “More actions” by default (triggerLabelchanges it), names the menu, and getsaria-haspopup="menu",aria-expandedand, while open,aria-controls. - The menu is
role="menu"withmenuitemrows,menuitemcheckboxrows witharia-checkedfor checkable items, androle="separator"dividers. A row with a submenu getsaria-haspopup="menu"andaria-expanded, and names the submenu. - Rows use a roving
tabindex. Disabled rows are skipped. - Right to left, ArrowLeft and ArrowRight swap.