$ rezi
Widgets

Accordion

Displays stacked sections that can be expanded or collapsed.

Displays stacked sections that can be expanded or collapsed.

Expanded content renders directly under its own header in item order.

Usage

ui.accordion({
  id: "faq",
  items: [
    { key: "install", title: "How do I install?", content: ui.text("Use npm or bun") },
    { key: "mouse", title: "Mouse support?", content: ui.text("Yes") },
  ],
  expanded: state.expanded,
  onChange: (expanded) => app.update({ expanded }),
  allowMultiple: false,
})

Props

PropTypeDefaultDescription
idstringrequiredStable accordion widget id
itemsArray\<{ key: string; title: string; content: VNode }>requiredAccordion sections
expandedstring[]requiredExpanded section keys
onChange(expanded: readonly string[]) => voidrequiredCalled when expansion changes
allowMultiplebooleanfalseAllows multiple expanded sections
keystring-Reconciliation key

Keyboard Behavior

  • Up/Down: moves focus between section headers.
  • Enter/Space: toggles the focused section.
  • Tab/Shift+Tab: enters/leaves accordion header focus.

On this page