Skip to content
Open
Show file tree
Hide file tree
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
10 changes: 10 additions & 0 deletions content/patterns/accordion/examples/accordion.html
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,16 @@ <h3>
<div role="separator" id="ex_end_sep" aria-labelledby="ex_end_sep ex_label" aria-label="End of"></div>
</section>

<section>
<h2>Accessibility Features</h2>
<ul>
<li>
Panels animate open and closed only for users who have not indicated a preference for reduced motion.
When a panel collapses, its content is hidden immediately, so it is removed from the accessibility tree and the tab sequence before the space it occupied finishes closing.
</li>
</ul>
</section>

<section>
<h2 id="kbd_label">Keyboard Support</h2>
<table aria-labelledby="kbd_label" class="def">
Expand Down
31 changes: 31 additions & 0 deletions content/patterns/accordion/examples/css/accordion.css
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,37 @@ button {
display: none;
}

/*
* Animate expand and collapse only when the user has not asked for reduced motion.
* Collapsed content becomes invisible immediately, so it leaves the accessibility
* tree and the tab order at once; only the space it occupied closes over time.
* Browsers without support for these features show and hide the panel instantly.
*/
@media (prefers-reduced-motion: no-preference) {
.accordion-panel {
interpolate-size: allow-keywords;
overflow: clip;
transition:
height 0.2s ease-out,
padding-block 0.2s ease-out,
display 0.2s allow-discrete;
}

.accordion-panel[hidden] {
height: 0;
padding-block: 0;
visibility: hidden;
}

/* Scoped to an accordion in use, so the initially open panel does not animate on page load */
@starting-style {
.accordion:is(:focus-within, :hover) .accordion-panel {
height: 0;
padding-block: 0;
}
}
}

fieldset {
border: 0;
margin: 0;
Expand Down
Loading