vael-ui v0.5.7

Navigation & menus

Layout

MenuList

Menu’s rows rendered in the page instead of a dropdown. Use it for a sidebar or settings navigation that stays on screen.

Install

import { MenuList } from 'vael-ui'

Playground

Usage
<script setup lang="ts">
import { MenuList } from 'vael-ui'

const items = [
  { label: 'Apple', value: 'apple' },
  { label: 'Banana', value: 'banana' },
  { label: 'Cherry', value: 'cherry' },
]
</script>

<template>
  <MenuList :items="items" />
</template>

Props

NameTypeDefaultDescription
itemsreadonly MenuEntry<T>[]Data-driven rows, in the same shape as Menu's items, so a MenuList and a Menu can share one array.
activestring | number | nullvalue of the current page; the matching row gets aria-current="page".
uiPartial<Record<'root' | 'item' | 'separator' | 'icon', UiPartValue>>Class and style overrides for each part.
motionMenuListMotionHow it moves: its appearance, row by row ({ initial: { item: { opacity: 0, x: -4 } }, stagger: 0.03 }), over root, item and the current page's indicator. spring retimes the indicator; move hands its moves to your own animation. false turns its own animation off.

Events

NameTypeDescription
select(item: T)Fires on click, or Enter/Space on a focused row.

Slots

NameTypeDescription
item{ item: T; isGroup: boolean; }Override one row's content while keeping its behavior. isGroup marks an inert group label (an entry with items, whose children render beneath it).
label{ item: T; isGroup: boolean; }Override a row's text only; its icon and shortcut stay.

Exposed

NameTypeDescription
elHTMLElement | nullRoot element.
indicatorElHTMLElement | nullThe current page's indicator, sliding between rows (null when no row is the current page).
highlightElHTMLElement | nullThe hover and keyboard highlight, sliding between rows. Under a ConfigProvider with motion: false it moves at once, for your own animation.
partsRecord<string, HTMLElement | HTMLElement[] | null>Its elements by part name, for your own animation; a repeated part is an array.

Motion New

MenuList: its appearance, and how the current-page indicator moves.

<MenuList
  :motion="{ initial: { item: { opacity: 0, y: 4 } } }"
/>
NameTypeDescription
initialexitrootitemindicatorSets 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.
move(parts, context) => animationMoves its sliding indicator. A spring retimes it, and a move hook animates it with your own library, starting from context.from.
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
TabMoves focus from row to row; each row is a Tab stop, like any link.
ArrowDownArrowUpMoves focus to the next or previous row, wrapping at the ends.
HomeEndMoves focus to the first or last row.
EnterSpaceActivates the focused row.
A letterMoves focus to the next row whose label starts with the typed letters.
  • Renders a <nav> landmark with native buttons or links, not menu roles. Pass aria-label when the page has more than one <nav>.
  • The row whose value matches active gets aria-current="page".
  • Group labels are plain text and aren’t focusable. Separators have role="separator".