vael-ui v0.5.7

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

Placement, behaviour and animation

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>

Props

NameTypeDefaultDescription
itemsRequiredreadonly MenuEntry<T>[]Dropdown rows, in the same shape as Menu's items.
variant'primary' | 'secondary' | 'outline' | 'ghost' | 'link' | 'text' | 'danger''primary'Visual style of both buttons.
size'sm' | 'md' | 'lg''md'Size of both buttons.
unifiedbooleanfalseJoins the two buttons into one surface, without the thin line between them.
disabledbooleanfalseDisables both buttons and blocks interaction.
loadingboolean | "auto"'auto'Forwarded to the main action Button only.
triggerLabelstringaria-label for the chevron button; uses the localized "More actions" when unset.
side'top' | 'right' | 'bottom' | 'left'Which side of the trigger the panel opens on.
align'start' | 'end' | 'center'How the panel aligns against the trigger along that side.
sideOffsetnumberGap between the trigger and the panel, in pixels.
alignOffsetnumberShifts the panel along the alignment axis, in pixels.
closeOnEscbooleanEscape key closes the panel.
closeOnOutsidebooleanClicking outside the panel closes it.
beforeCloseBeforeClose<PopoverCloseReason>Runs before the menu closes. Return true to close it, false to keep it open, or a promise of either, like () => confirmAction(…).result. The menu stays open while the promise is pending.
forceMountbooleanKeeps the panel mounted while closed, toggled with v-show, so its content keeps its state. vael-ui then leaves its motion to you.
motionMenuMotionHow the menu moves, like Menu's. false opens and closes it at once. An object moves it your way: values for the panel part, { spring }, or enter / leave hooks. Unset, it follows the nearest ConfigProvider's style.
teleportTostring | HTMLElementTeleport target: a CSS selector or element.
scrollFadebooleanMasks the panel's top/bottom edge as its content scrolls under it, signaling there's more.
uiPartial<Record<'root' | 'main' | 'trigger' | 'positioner' | 'panel' | 'header' | 'footer' | 'chevron', UiPartValue>>Class and style overrides for each part.
openbooleanfalseWhether the dropdown menu is open.

Events

NameTypeDescription
open-change(value: boolean, details: PopoverOpenChangeDetails)Fires before the menu closes; details has the reason and a cancel() that keeps it open.
select(item: T)Fires when a dropdown item is chosen.
update:open(value: boolean)Fires when open changes (v-model:open).

Slots

NameTypeDescription
defaultanyMain action button content.
headeranyForwarded to the dropdown Menu's own #header.
item{ item: T; }Custom content for one dropdown row, keeping its behavior; forwarded to Menu's own #item.
label{ item: T; }Override a row's text only; its icon and shortcut stay. Forwarded to Menu's own #label.

Exposed

NameTypeDescription
elHTMLElement | nullRoot element.
mainElHTMLElement | nullMain action button element.
triggerElHTMLElement | nullChevron button element that opens the menu.
panelElHTMLElement | nullPanel element (null while closed).
positionerElHTMLElement | nullPositioning wrapper around the panel (null while closed).
isClosingbooleantrue while a beforeClose close is pending.
open() => voidOpens the menu.
close() => voidCloses the menu, running beforeClose first.
cancelClose() => voidCancels a close pending in beforeClose and keeps the menu open.

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 },
  }"
/>
NameTypeDescription
initialexitpositionerpanelSets 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.
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 | 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

Follows the Menu Button pattern from the WAI-ARIA Authoring Practices Guide.

KeyAction
EnterSpaceRuns the main action, or opens the menu from the arrow button.
ArrowDownOpens the menu from the arrow button and focuses the first item.
ArrowUpOpens the menu from the arrow button and focuses the last item.
ArrowDownArrowUpMoves to the next or previous item in the menu, wrapping at the ends.
HomeEndMoves to the first or last item.
EnterSpaceActivates the focused item and closes the menu, unless the item has keepOpen.
ArrowRightOpens the focused item’s submenu.
ArrowLeftCloses the submenu and focuses its parent item.
A letterMoves to the next item whose label starts with the typed letters.
EscapeCloses the innermost open menu and returns focus to what opened it.
TabShiftTabCloses 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 (triggerLabel changes it), names the menu, and gets aria-haspopup="menu", aria-expanded and, while open, aria-controls.
  • The menu is role="menu" with menuitem rows, menuitemcheckbox rows with aria-checked for checkable items, and role="separator" dividers. A row with a submenu gets aria-haspopup="menu" and aria-expanded, and names the submenu.
  • Rows use a roving tabindex. Disabled rows are skipped.
  • Right to left, ArrowLeft and ArrowRight swap.