Accordion

A vertically stacked set of interactive headings that each reveal a section of content.

Anatomy

Accordion do |a|
a.item do
a.trigger
a.content
end
a.item do
a.trigger
a.content
end
end

API Reference

Accordion

NameTypeDefault
value:string or arraynil
The value(s) of the item(s) to expand when initially rendered. Can be a single string or array of strings.
multiple:booleanfalse
Determines whether one or multiple items can be opened at the same time. When true, multiple items can be expanded simultaneously.
attributeskeyword arguments

Accordion#item

NameTypeDefault
required value:string
Unique identifier for this accordion item. Used to control which items are open/closed.
attributeskeyword arguments

Accordion#trigger

NameType
attributeskeyword arguments

Accordion#content

NameType
attributeskeyword arguments

Keyboard Interactions

KeyDescription
SpaceWhen focus is on a trigger of a collapsed section, expands the section.
EnterWhen focus is on a trigger of a collapsed section, expands the section.
TabMoves focus to the next focusable element.
Shift+TabMoves focus to the previous focusable element.
ArrowDownMoves focus to the next trigger.
ArrowUpMoves focus to the previous trigger.

Examples