All effectsClick & switch

Accordion Expand

手风琴展开

A row control expands or collapses the content panel directly beneath it.

Open and close the rows

Where to use it

Keep FAQs, grouped settings, and long descriptions easy to scan. Keep the row label visible above its expanded content so readers can close it from the same place.

Practical example

In a hotel booking FAQ, opening “What if I arrive late?” unfolds check-in instructions under that question. The guest can keep scanning the questions below it.

AI prompt

Add Accordion Expand to [target rows]. Keep the current disclosure semantics or use details and summary. Animate the opening panel around its natural content height and synchronize the expanded state with the indicator. Preserve the keyboard order, hide closed content from focus, and use an instant transition with reduced motion.

Example code

Save the standalone HTML as a file and open it in your browser. It uses the same code as the preview.

View HTML
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Accordion Expand</title>
  <style>
    :root {
      color-scheme: dark;
      --demo-bg: #171629;
      --demo-ink: #f8f5ff;
      --demo-accent: #b9a6ff;
      --demo-muted: #bfbbd3;
      font-family: system-ui, sans-serif;
      color: var(--demo-ink);
      background: var(--demo-bg);
    }

    *, *::before, *::after { box-sizing: border-box; }
    body { margin: 0; min-width: 0; }
    button, input { font: inherit; }

    .demo {
      display: grid;
      place-items: center;
      align-content: center;
      min-height: 100vh;
      padding: 14px;
      overflow: hidden;
      background: radial-gradient(ellipse at 50% 24%, #28233f, var(--demo-bg) 78%);
    }

    .demo-button {
      border: 1px solid #ffffff3d;
      border-radius: 7px;
      background: #ffffff12;
      color: var(--demo-ink);
      padding: 6px 11px;
      font-size: 12px;
      cursor: pointer;
    }

    :focus-visible {
      outline: 2px solid var(--demo-accent);
      outline-offset: 3px;
    }

    .accordion-demo {
      display: grid;
      gap: 5px;
      width: min(100%, 228px);
      interpolate-size: allow-keywords;
    }
    .accordion-item {
      color: #f3eaff;
      background: #30243f;
      border: 1px solid #624e7a;
      border-radius: 8px;
    }
    .accordion-item summary {
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 7px;
      padding: 8px 11px;
      border-radius: 7px;
      font-size: 11px;
      font-weight: 650;
      cursor: pointer;
    }
    .accordion-item summary::-webkit-details-marker { display: none; }
    .accordion-item summary i {
      width: 7px;
      height: 7px;
      border-right: 1.5px solid #cbb1ff;
      border-bottom: 1.5px solid #cbb1ff;
      transform: translateY(-2px) rotate(45deg);
      transition: transform 220ms ease;
    }
    .accordion-item[open] summary i { transform: translateY(2px) rotate(225deg); }
    .accordion-item p { margin: 0; padding: 0 11px 9px; color: #d5c5e7; font-size: 10px; }
    @supports selector(::details-content) {
      .accordion-item::details-content {
        block-size: 0;
        overflow: clip;
        transition: block-size 220ms ease, content-visibility 220ms allow-discrete;
      }
      .accordion-item[open]::details-content { block-size: auto; }
    }
    @media (prefers-reduced-motion: reduce) {
      .accordion-item summary i { transition: none; }
      .accordion-item::details-content { transition: none; }
    }
  </style>
</head>
<body>
  <main class="demo">
    <div class="accordion-demo">
      
      <details class="accordion-item" name="gallery">
        <summary><span>Opening hours</span><i aria-hidden="true"></i></summary>
        <p>Tuesday to Sunday from 10 a.m.</p>
      </details>
      <details class="accordion-item" name="gallery">
        <summary><span>Gallery route</span><i aria-hidden="true"></i></summary>
        <p>Start at the main entrance and follow the long hall.</p>
      </details>
    </div>
  </main>
</body>
</html>

Original example by UI Skills