Accordion Example
Please provide feedback for this example in issue 210.
The below example section contains a simple personal information input form divided into 3 sections that demonstrates the design pattern for accordion. In this implementation, one panel of the accordion is always expanded, and only one panel may be expanded at a time. This example does not implement any of the optional keystrokes included in the accordion pattern.
Example
Keyboard Support
Key | Function |
---|---|
Space or Enter | When focus is on the accordion header of a collapsed section, expands the section. |
Role, Property, State, and Tabindex Attributes
Role | Attribute | Element | Usage |
---|---|---|---|
heading |
dt |
|
|
aria-level= |
dt |
Specifies heading level for the accordion header. | |
button |
a |
A button inside the accordion header that provides hide/show functionality. | |
aria-expanded= |
a |
Set to true when the Accordion panel is expanded, otherwise set to false .
|
|
aria-controls= |
a |
Points to the ID of the panel which the header controls. | |
aria-disabled= |
a |
If the accordion panel is expanded and is not allowed to be collapsed, then set to true .
|
|
region | dd |
Creates a landmark region that contains the currently expanded accordion panel. | |
aria-labelledby="ID_REF" |
dd |
|
Javascript and CSS Source Code
- CSS:
- JavaScript: