vael-ui v0.5.7

Layout & structure

Layout

Accordion

A stack of collapsible sections where opening one can close the others. Use it for FAQs or long content split into sections.

Install

import { Accordion } from 'vael-ui'

Playground

Usage
<script setup lang="ts">
import { Accordion, AccordionItem } from 'vael-ui'
</script>

<template>
  <Accordion>
    <AccordionItem value="item-1" title="What is vael-ui?">
      A Vue 3 component library with a full Vue Vapor build.
    </AccordionItem>
    <AccordionItem value="item-2" title="Does it support dark mode?">
      Yes. It follows the system setting, and a data-theme attribute on the root element overrides it.
    </AccordionItem>
    <AccordionItem value="item-3" title="Can I use my own animation library?">
      Yes. Every animated component has hooks for GSAP, motion-v, or plain CSS.
    </AccordionItem>
  </Accordion>
</template>

Props

NameTypeDefaultDescription
multiplebooleanfalseLets several items be open at once; the model becomes an array.
collapsiblebooleantrueWhether the last open item can close, leaving none open.
motionAccordionMotiontruefalse turns the transitions off, so you can animate each item's exposed panelEl and chevronEl yourself. An object animates each item's states, like a quarter-turn chevron: { states: { open: { chevron: { rotate: '90deg' } } } }.
headingLevel1 | 2 | 3 | 4 | 5 | 63Heading level wrapping each item's trigger; match it to the surrounding outline.
uiPartial<Record<'root', UiPartValue>>Class and style overrides for each part.
valueVnullOpen item's value (a string, or a union of your item values), or an array of them with multiple. V takes the type you bind, and @change hands the same type back.

Events

NameTypeDescription
change(value: V)Fires when an item opens or closes, with the new value.
update:value(value: V | undefined)Fires when value changes (v-model:value).

Slots

NameTypeDescription
defaultanyThe AccordionItems.

Exposed

NameTypeDescription
elHTMLElement | nullRoot element.

Motion New

Accordion's motion: values or hooks for its parts (AccordionPart), its states (open, disabled). false turns it off.

<Accordion
  :motion="{ states: { open: { panel: { scale: 1.04 } } } }"
/>
NameTypeDescription
initialexititemheadertriggerchevronpanelbodySets 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.
statesopendisabledSets 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) => animationAnimates 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 | 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 Accordion pattern from the WAI-ARIA Authoring Practices Guide.

KeyAction
EnterSpaceOpens or closes the focused section.
ArrowDownArrowUpMoves focus to the next or previous header, wrapping at the ends.
HomeEndMoves focus to the first or last header.
  • Each header is a <button> with aria-expanded and aria-controls, inside an <h3>. Set headingLevel to match your page outline.
  • Each panel has role="region" and aria-labelledby pointing at its header. A closed panel stays mounted as hidden="until-found": out of the tab order and the accessibility tree, but the browser's find reaches it and opens its section. Where a browser has no until-found, it is aria-hidden and inert instead.
  • A disabled item has a native disabled button, so Tab and the arrow keys skip it.
  • The arrow keys move only between this Accordion's own headers, so a nested Accordion keeps its own. With collapsible set to false, the last open section stays open, and its header is aria-disabled but still focusable.