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>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 } } } }"
/>| Name | Type | Description |
|---|---|---|
initialexit | itemheadertriggerchevronpanelbody | 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 | opendisabled | 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 Accordion pattern from the WAI-ARIA Authoring Practices Guide.
| Key | Action |
|---|---|
| EnterSpace | Opens or closes the focused section. |
| ArrowDownArrowUp | Moves focus to the next or previous header, wrapping at the ends. |
| HomeEnd | Moves focus to the first or last header. |
- Each header is a
<button>witharia-expandedandaria-controls, inside an<h3>. SetheadingLevelto match your page outline. - Each panel has
role="region"andaria-labelledbypointing at its header. A closed panel stays mounted ashidden="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 nountil-found, it isaria-hiddenandinertinstead. - A disabled item has a native
disabledbutton, 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
collapsibleset tofalse, the last open section stays open, and its header isaria-disabledbut still focusable.