diff --git a/docs/api/accordion.mdx b/docs/api/accordion.mdx index 02bdc9e78d..df59d44974 100644 --- a/docs/api/accordion.mdx +++ b/docs/api/accordion.mdx @@ -9,6 +9,9 @@ import Parts from '@ionic-internal/component-api/v9/accordion/parts.mdx'; import CustomProps from '@ionic-internal/component-api/v9/accordion/custom-props.mdx'; import Slots from '@ionic-internal/component-api/v9/accordion/slots.mdx'; +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + ion-accordion: Accordion Components: How to Build & Examples +### Heading Level {/* #heading-level */} + +:::note + +The `headingLevel` property is supported starting in Ionic v9.1. + +::: + +By default, accordion headers are not exposed to assistive technology as headings. Setting the `headingLevel` property on `ion-accordion-group` to a value from `1` to `6` gives each accordion header in the group a heading role with that level. When the header is an `ion-item`, the heading contains the button that expands or collapses the accordion, so screen reader users can jump between accordions using heading navigation. Do not place a heading element around or inside the `ion-item` in the `header` slot, as this places one heading inside another. + +Choose a level that fits the heading structure of the page. For example, if the accordions are inside a section titled with an `h2`, set `headingLevel` to `3`. + +All accordions in a group share the same heading level. A nested accordion group does not inherit the heading level of the group it is inside of, so set `headingLevel` on the nested group as well, usually to one level deeper than the outer group. To expose the header of a single accordion as a heading, place it inside an `ion-accordion-group` and set `headingLevel` on the group. + + + + + +```html +

Frequently Asked Questions

+ + + + First Accordion + +
First Content
+
+ + + Second Accordion + +
Second Content
+
+
+``` + +
+ + + +```html +

Frequently Asked Questions

+ + + + First Accordion + +
First Content
+
+ + + Second Accordion + +
Second Content
+
+
+``` + +
+ + + +```tsx +<> +

Frequently Asked Questions

+ + + + First Accordion + +
+ First Content +
+
+ + + Second Accordion + +
+ Second Content +
+
+
+ +``` + +
+ + + +```html +

Frequently Asked Questions

+ + + + First Accordion + +
First Content
+
+ + + Second Accordion + +
Second Content
+
+
+``` + +
+ +
+ ### Keyboard Interactions {/* #keyboard-interactions */} When used inside an `ion-accordion-group`, `ion-accordion` has full keyboard support for interacting with the component. The following table details what each key does: