Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions articles/components/accordion/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,39 @@
endif::[]
--

== 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.

Check warning on line 144 in articles/components/accordion/index.adoc

View workflow job for this annotation

GitHub Actions / lint

[vale] reported by reviewdog 🐶 [Vaadin.Abbr] 'WAI' has no definition. Raw Output: {"message":"[Vaadin.Abbr] 'WAI' has no definition.","location":{"path":"articles/components/accordion/index.adoc","range":{"start":{"line":144,"column":189},"end":{"line":144,"column":192}}},"severity":"WARNING","code":{"value":"Vaadin.Abbr"}}

By default, the headings have no level, so screen readers announce them at their default level. The `aria-level` attribute can be [since:com.vaadin:vaadin@V25.3]#customized# to match the surrounding page structure -- for example, level 3 inside a section with an `<h2>` title:

[.example]
--
ifdef::flow[]
[source,java]
----
accordion.setHeadingLevel(3);
----
endif::[]

ifdef::lit[]
[source,html]
----
<vaadin-accordion heading-level="3">
----
endif::[]

ifdef::react[]
[source,tsx]
----
<Accordion headingLevel={3}>
----
endif::[]
--

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.
Expand Down
Loading