---
title: "Accessible CSS Transitions: Build a Disclosure That Respects Reduced Motion"
description: "Build a keyboard-accessible shipping disclosure in HTML, CSS, and JavaScript. Compare linear and ease-out timing, watch how reduced motion changes the interaction, and test the result in your browser."
author: "Jordan Hudgens"
author_handle: "@jordan"
canonical_url: "https://www.devguides.com/jordan/accessible-css-transitions-disclosure-reduced-motion"
published_at: "2026-11-21T20:19:41.204599+00:00"
updated_at: "2026-11-21T20:19:41.204599+00:00"
reading_minutes: 6
topics: ["css", "accessibility", "javascript"]
---

# Accessible CSS Transitions: Build a Disclosure That Respects Reduced Motion

> Build a keyboard-accessible shipping disclosure in HTML, CSS, and JavaScript. Compare linear and ease-out timing, watch how reduced motion changes the interaction, and test the result in your browser.

You press **Shipping details**. The answer appears, and a small arrow turns toward it. Now tap twice in quick succession. If the arrow points down over an empty panel, the component has lost track of its state. A shorter animation might hide the problem, but you can fix it at the source.

In this guide you’ll build a disclosure with plain HTML, CSS, and a few lines of JavaScript. The panel responds on every press, the arrow can reverse halfway through a turn, and readers who prefer reduced motion get the same information immediately.

## Start with two states

A *disclosure* is a button that shows or hides associated content. For this one, write down what must be true after each press.

| State | Button announces | Shipping information | Chevron |
| --- | --- | --- | --- |
| Closed | Collapsed | Hidden | Points right |
| Open | Expanded | Visible | Points down |

![Closed and open shipping disclosures showing the matching button state, panel visibility, and chevron direction.](https://www.devguides.com/api/media?path=devguides%2F8f6b6a61-d3c6-4277-8bf5-0cd4e1a800cd%2F643f9f77-8638-4c69-ba9d-bfac6f89e977.png)

The panel’s `hidden` property tells the click handler which state comes next. The handler also updates `aria-expanded` on the button. CSS reads that attribute to aim the arrow. There is no third “animating” state to reconcile after a rapid second press. This follows the [WAI disclosure pattern](https://www.w3.org/WAI/ARIA/apg/patterns/disclosure/).

## Build the disclosure

Create an empty folder with three files named `index.html`, `disclosure.js`, and `disclosure.css`. Save the following snippets in those files, then open `index.html` in your browser. The example runs directly from disk.

### 1. Make the information available first

With JavaScript disabled, the page still answers the shipping question. The paragraph starts visible and the button starts hidden. The deferred script will attach a handler before revealing the button.

```html
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Shipping details disclosure</title>
  <link rel="stylesheet" href="disclosure.css">
  <script src="disclosure.js" defer></script>
</head>
<body>
  <main>
    <h1>Delivery</h1>
    <button id="shipping-toggle" type="button" hidden
            aria-controls="shipping-info" aria-expanded="true">
      <span class="chevron" aria-hidden="true"></span>
      Shipping details
    </button>
    <p id="shipping-info">Orders dispatch within two business days.</p>
  </main>
</body>
</html>
```

### 2. Update the panel and the button together

Save this as `disclosure.js`. When the panel is hidden, `panel.hidden` is `true`, so the next press passes `true` to `setExpanded` and opens it. A native button already handles Enter and Space. Adding another keyboard handler can toggle the panel twice.

```js
const button = document.querySelector("#shipping-toggle");
const panel = document.querySelector("#shipping-info");

function setExpanded(expanded) {
  panel.hidden = !expanded;
  button.setAttribute("aria-expanded", String(expanded));
}

button.addEventListener("click", () => setExpanded(panel.hidden));
setExpanded(false);
button.hidden = false;
```

### 3. Animate just the arrow

Save this as `disclosure.css`. The small triangle is decorative, so the markup hides it from assistive technology. The button’s accessible name stays “Shipping details” in both states.

```css
body {
  margin: 2rem;
  color: #172b36;
  font: 1.1rem/1.5 system-ui, sans-serif;
}

#shipping-toggle {
  padding: .65em 1em;
  font: inherit;
  color: inherit;
  background: #effaf7;
  border: 1px solid #506d68;
  border-radius: .5em;
  cursor: pointer;
}

#shipping-toggle:focus-visible {
  outline: 3px solid #145eaa;
  outline-offset: 3px;
}

.chevron {
  display: inline-block;
  width: .65em;
  height: .65em;
  margin-inline-end: .35em;
  background: currentColor;
  clip-path: polygon(20% 0, 95% 50%, 20% 100%);
  transform: rotate(0deg);
}

[aria-expanded="true"] .chevron {
  transform: rotate(90deg);
}

@media (prefers-reduced-motion: no-preference) {
  .chevron {
    transition: transform 180ms ease-out;
  }
}
```

The transition belongs on `.chevron` so it applies when opening **and** closing. Both end positions work without any transition. Only readers whose device reports `no-preference` get the movement. [W3C reduced-motion technique](https://www.w3.org/WAI/WCAG22/Techniques/css/C39)

## Read an easing curve

Duration answers “when will the arrow arrive?” Easing answers “how far has it turned by now?” Imagine pausing the 180 ms turn at 90 ms. With `linear`, the arrow is at 45°. With CSS `ease-out`, it has already covered about 68% of its travel, or roughly 62°. Both arrive at 90° at the same time. The CSS keyword `ease-out` corresponds to `cubic-bezier(0, 0, 0.58, 1)`. [CSS Easing Functions specification](https://www.w3.org/TR/css-easing-1/#cubic-bezier-easing-functions)

![Progress versus elapsed time for linear and ease-out. Halfway through, linear has covered 50 percent of the distance and ease-out about 68 percent.](https://www.devguides.com/api/media?path=devguides%2F8f6b6a61-d3c6-4277-8bf5-0cd4e1a800cd%2F5c87343b-dedf-4fd8-ab7a-8ef54750e5ef.png)

The clip stretches a trip to two seconds and uses a straight track to make the difference easy to see. Watch which marker first passes the middle of the track, then watch when each reaches the end.

[Guide animation](https://www.devguides.com/api/media?path=devguides%2F8f6b6a61-d3c6-4277-8bf5-0cd4e1a800cd%2Fce79f8ed-c7bb-4171-9650-0b39741943ce.mp4)

## Lab: Make the difference visible

1. Open your example and press Tab until **Shipping details** has the focus ring. Press Enter to open the panel, then Space to close it. Focus should stay on the button.
2. Temporarily change `180ms` to `2s` and reload. Click once, then click again before the arrow finishes. The paragraph should respond on each press, even while the arrow is partway through its turn.
3. Switch `ease-out` to `linear` and repeat. Look at the last quarter of the turn. Linear keeps a steady pace, while ease-out slows as it approaches the final angle. Restore `180ms ease-out` afterward.
4. In Chrome DevTools, open the command menu, choose **Show Rendering**, and emulate `prefers-reduced-motion: reduce`. Toggle the panel again. The arrow should point in the new direction immediately. Switch back to `no-preference` and repeat. [Chrome Rendering panel](https://developer.chrome.com/docs/devtools/rendering/emulate-css/)

This side-by-side replay slows the gesture down fourfold. In both panels the shipping information appears immediately. Watch the arrow on the reduced-motion side jump directly to its final angle. On closing, the text disappears on both sides while the other arrow settles back.

[Guide animation](https://www.devguides.com/api/media?path=devguides%2F8f6b6a61-d3c6-4277-8bf5-0cd4e1a800cd%2F4460076d-2756-47aa-aa85-11e911954008.mp4)

## Diagnose a mismatch

| Symptom | Where to look | Fix |
| --- | --- | --- |
| One Space press opens and closes the panel | Separate key and click handlers | Keep the native button and handle its click once. |
| The arrow eases open but snaps shut | Transition declared only under the expanded selector | Put the transition on the chevron in both states. |
| The panel waits after each press | Visibility tied to a timer or a transition-end handler | Set `hidden` in the click handler. |
| The content vanishes when scripts fail | Panel hidden in the initial markup | Start with visible content and collapse it after attaching the handler. |

> A good final check is to disable the transition entirely. You should still be able to find the button, open it with the keyboard, read the shipping answer, and close it again.

Try the same pattern on a second disclosure. Give it its own button, panel, and unique `aria-controls` target. Tab between them and verify that opening one changes only the content it controls.
