Repository navigation
docs(accordion): document headingLevel property for accessibility - #4919
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
1 of 2 tasks
brandyscarney
added a commit
to ionic-team/ionic-framework
that referenced
this pull request
Dec 2, 2026
Issue number: resolves #31621 --------- <!-- Please do not submit updates to dependencies unless it fixes an issue. --> <!-- Please try to limit your pull request to one type (bugfix, feature, etc). Submit multiple pull requests if needed. --> ## What is the current behavior? <!-- Please describe the current behavior that you are modifying. --> Accordion headers can't be exposed as headings, so screen reader users can't jump between accordions with heading navigation (VoiceOver rotor, NVDA/JAWS `H` key). The WAI-ARIA accordion pattern wraps each header button in a heading, but there's no way to get that structure today. Wrapping the `ion-item` in an `h3` stops it from becoming the toggle button, and `ion-item` overrides any `role` set on it. ## What is the new behavior? <!-- Please describe the behavior or changes that are being added by this PR. --> - Added a `headingLevel` property to `ion-accordion-group` (`heading-level` attribute, `1` to `6`). When it's set, each accordion in the group exposes its header as a heading with that level. When the header is an `ion-item`, the heading contains its toggle button: `heading (level 3) > button (expanded/collapsed)`. It's opt-in, so groups without it don't change. - The level is set on the group because accordions in a group are sibling sections, so they share one level. A nested group sets its own `headingLevel` and doesn't inherit one. - Removing the attribute or binding `null` removes the heading. Values that aren't a whole number from `1` to `6` don't add a heading and log a warning, since a heading without a valid `aria-level` would be announced as level 2. - Accordions re-render when the group's level changes and whenever they're connected, so an accordion added after load, moved to another group, or removed and added back picks up the current level. - There's no visual change. Only the accessibility tree changes, so no screenshots were updated. ## Does this introduce a breaking change? - [ ] Yes - [X] No <!-- If this introduces a breaking change: 1. Describe the impact and migration path for existing applications below. 2. Update the BREAKING.md file with the breaking change. 3. Add "BREAKING CHANGE: [...]" to the commit description when merging. See https://github.com/ionic-team/ionic-framework/blob/main/docs/CONTRIBUTING.md#footer for more information. --> ## Other information Docs PR: ionic-team/ionic-docs#4919 To try it, open the [basic test page](https://ionic-framework-git-fw-7908-ionic1.vercel.app/src/components/accordion/test/basic?ionic:mode=md), run this in the console, then inspect an accordion header in the Accessibility pane of the browser dev tools: ```js document.querySelectorAll('ion-accordion-group').forEach((g) => (g.headingLevel = 3)); ``` --------- Co-authored-by: Brandy Smith <6577830+brandyscarney@users.noreply.github.com>
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a Heading Level section under Accessibility in the accordion docs for the new
headingLevelproperty onion-accordion-groupfrom ionic-team/ionic-framework#31852. The section explains how setting the property exposes each accordion header as a heading so screen reader users can navigate between accordions, how to choose a level that fits the page's heading structure, and how nested accordion groups need their ownheadingLevel. It includes a note that the property is supported starting in v9.1.Since the property has no visual effect, the section uses framework tabs with code samples (matching the accessibility examples on Alert and Action Sheet) rather than a playground.
Accordion heading level docs