Accordion
Accordion is a vertically stacked set of expandable panels. It reduces clutter and helps maintain the user’s focus by showing only the relevant content at any time.
Source code
AccordionBasic.java
accordion-basic.tsx
accordion-basic.ts
Anatomy
Accordion consists of stacked panels, each composed of two parts: a summary and a content area. Only one panel can be expanded at a time. Use the Details component to allow multiple, simultaneously expanded sections.
Summary
The summary is the part that’s always visible, and typically describes the content, for example, with a title. Clicking on the summary toggles the content area’s visibility.
The summary supports rich content and can contain any component. This can be utilized, for example, to display the status of the corresponding content.
Source code
AccordionSummary.java
accordion-summary.tsx
accordion-summary.ts
Content
This is the collapsible part of a panel. It can contain any component. When the content area is collapsed, the content is invisible and inaccessible by keyboard or screen reader.
Source code
AccordionContent.java
accordion-content.tsx
accordion-content.ts
Disabled Panels
Accordion panels can be disabled to prevent them from being expanded or collapsed. Details can also be disabled to prevent them from being expanded or collapsed. Components inside a disabled expanded panel are automatically disabled as well.
Source code
AccordionDisabledPanels.java
accordion-disabled-panels.tsx
accordion-disabled-panels.ts
Accessibility
Each panel’s summary is rendered as a heading — an element with role="heading" that wraps a button — and the panel’s content as a region labeled by that heading, as recommended by the WAI-ARIA accordion pattern. Screen readers can therefore list the summaries as headings and announce whether each panel is expanded or collapsed.
By default, the headings have no level, so screen readers announce them at their default level. The aria-level attribute can be customized to match the surrounding page structure — for example, level 3 inside a section with an <h2> title:
Source code
Java
accordion.setHeadingLevel(3);HTML
<vaadin-accordion heading-level="3">tsx
<Accordion headingLevel={3}>The same level is applied to all panel headings.
Best Practices
Accordions are suitable when users need to focus on smaller pieces of content at any given time. However, when all of the content is relevant to the user to make a decision, Accordions should be avoided. Content areas that are logically linked should be grouped together in one panel.
Accordions are better suited than Tabs for long labels. However, Accordions can feel jumpy as panels are toggled — especially if there are several panels or the panel content is long.
Details can be used instead of Accordion when there is a need to see content from multiple panels, simultaneously.
Accordions can be used to break a complex form into smaller step-by-step sections.
The expandable and collapsible nature of accordions can sometimes be difficult for users to discover. Use the filled variant and apply tooltips on the panels to make this more discoverable.