Layout & structure
Layout
Collapsible
A single section that shows and hides its content. Use it for optional or secondary content.
Install
import { Collapsible } from 'vael-ui'Playground
Usage
<script setup lang="ts">
import { ref } from 'vue'
import { Collapsible, Button } from 'vael-ui'
const open = ref(false)
</script>
<template>
<Collapsible v-model:open="open">
<template #trigger>
<Button variant="outline">{{ open ? 'Close' : 'Open' }}</Button>
</template>
<p>Toggle to reveal this content.</p>
</Collapsible>
</template>Motion New
Collapsible: its appearance and states. */ type CollapsibleHook = MotionHook< CollapsiblePart | 'body', { signal: AbortSignal; reducedMotion: boolean } > /** Collapsible: its appearance and states, and your own opening and closing. With a hook its height no longer eases: enter runs once the panel is open (animate it from closed), and leave before it closes, which waits for what it returns.
<Collapsible
:motion="{ states: { open: { panel: { scale: 1.04 } } } }"
/>| Name | Type | Description |
|---|---|---|
initialexit | roottriggerpanel | 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 Disclosure pattern from the WAI-ARIA Authoring Practices Guide.
| Key | Action |
|---|---|
| EnterSpace | Opens or closes the panel from the trigger button. |
- Put a
<button>in the#triggerslot. The firstbutton,[role="button"]ora[href]in it getsaria-expandedandaria-controls. - Keyboard support comes from the element you put in the slot. The wrapper around it only listens for clicks.
- With
disabled, the trigger getsaria-disabled="true"and clicks do nothing. - The panel has
role="region", named by the trigger. 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 it. Where a browser has nountil-found, it isaria-hiddenandinertinstead.