Skip to main content

Accordion

Expandable content sections with accessible keyboard navigation.

Usage

<w-accordion value="item1">
<w-slot item name="item1">
<w-slot trigger><button>Section 1</button></w-slot>
<w-slot body>
<div>Content for section 1</div>
</w-slot>
</w-slot>

<w-slot item name="item2">
<w-slot trigger><button>Section 2</button></w-slot>
<w-slot body>
<div>Content for section 2</div>
</w-slot>
</w-slot>
</w-accordion>

Props

PropTypeDefaultDescription
valuestring""Expanded item name(s), comma-separated for multiple
multiplebooleanfalseAllow multiple items to be expanded
collapsiblebooleantrueAllow all items to be collapsed

Slots

SlotElementDescription
itemContainerWrapper for each accordion item (requires name attribute)
triggerButtonClickable header that toggles the item
contentAnyCollapsible content area

Events

EventDetailDescription
change{ value, expanded, toggled, isExpanded }Fired when an item is toggled

Methods

MethodDescription
expand(name)Expand a specific item
collapse(name)Collapse a specific item
expandAll()Expand all items (requires multiple)
collapseAll()Collapse all items (requires collapsible)

Keyboard

KeyAction
Enter / SpaceToggle focused item
ArrowDownFocus next trigger
ArrowUpFocus previous trigger
HomeFocus first trigger
EndFocus last trigger

Examples

Multiple Selection

<w-accordion multiple value="item1,item2">
<!-- Multiple items can be open -->
</w-accordion>

Non-Collapsible

<w-accordion collapsible="false" value="item1">
<!-- At least one item always open -->
</w-accordion>

Accessibility

  • Uses aria-expanded on triggers
  • Uses aria-controls to link triggers to content
  • Content regions have aria-labelledby pointing to trigger
  • Full keyboard navigation support