Skip to content
SkillCodex
Menu

Accordion

Accordion

A vertical set of headings that reveals or hides each associated content section.

Try the component
Context, sources and actions
Sources and revision
Updated
Version
v1.0.26 · r2
Sources
5 sources
Status
Published
Read the sources

You may have searched for: questions that open answers underneathclick a heading to expand its sectiona vertical list of collapsible content

All phrasings
Save and share

Recognize

Change view or reveal content

Try it

Should the control switch views, choose a compact mode, or reveal content in the flow?

Accordion

Shared trial context

A project workspace reveals related content in place while preserving the user's position on the page.

Accordion

Mission

Accordion

Expand Refunds, move to Payment methods with keyboard, open it, and collapse Refunds again.

Essential information, always open

This answer must remain visible to complete the process.

Live result

Only the mandatory section remains open.

Step 1 of 3

Try

Try the component. Your live result appears just above. Move on at your own pace.

Behavior and edge case
What to observe
The expanded header exposes its state and the answer appears immediately after it.
Edge case
A mandatory open section cannot be collapsed and communicates that rule without presenting a false control.

What this example shows

Accordion reveals sections beneath their headings; Tabs swaps one peer panel, while Segmented control selects one compact value.

Which fits your need?

Accordion

Organizing FAQ answers or optional detail sections

Tabs

Grouping a few peer views in one workspace

Which component will you use here?
Difference and sources

Accordion reveals sections beneath their headings; Tabs swaps one peer panel, while Segmented control selects one compact value.

Read the sources

    Parts of the specimen

    Select a numbered marker on the schematic, or use the list below, to see its role. The schematic shows the concept's representative state.

    Heading

    A meaningful heading that introduces the message or disclosure.

    Position in the atlas

    Relationship map

    Locate the chapter, neighboring concepts, and the next useful decision.

    • Chapter

      Change view or reveal content

      Accordion belongs to this comparison group.

    • Do not confuse

      Tabs

      Choose Accordion if several sections may stay open at once and read top to bottom, like a FAQ. Choose Tabs if the views are peers and only one should occupy the space at a time.

      Compare this pair
    • Do not confuse

      Segmented control

      Choose Accordion if the user opens optional detail sections, like FAQ answers, and may leave several open. Choose Segmented control if the user switches a compact setting or display mode among two to five values.

      Compare this pair
    • Next step

      Compare the concepts in the chapter before choosing an implementation.

      Open the chapter

    In your own words

    Understand

    What people describe

    Documented aliases: expandable sections, collapsible panels, disclosure list

    • questions that open answers underneath
    • click a heading to expand its section
    • a vertical list of collapsible content
    • show and hide details one row at a time
    • an FAQ with expandable answers
    • open several sections without changing page

    Choose

    Use it when

    • Organizing FAQ answers or optional detail sections
    • Letting users scan headings before opening relevant content

    Avoid it when

    • All content is short enough to show directly
    • The sections are primary destinations that need URLs

    Compare

    Compare similar concepts

    Verification checklist

    Try these actions in the lab, then check the same behaviours in your agent’s result. Adapt the example names to your interface.

    1. 1. Do this

      Focus a section heading and press Enter or Space to open and close it.

      Expected result

      Only its associated content changes, the expanded state is exposed, and focus stays on the heading button.

    2. 2. Do this

      Open a second section while the first is already open.

      Expected result

      The result follows the stated single-open or multiple-open rule; a required open section is not offered as freely collapsible.

    3. 3. Do this

      Open a section and read its text, then close it and continue with Tab; if it contains links or controls, check that they are skipped when closed.

      Expected result

      The closed section’s content is hidden and creates no invisible keyboard stops; its heading remains reachable to reopen it.

    Full contract
    1. 1Every header is a real button inside a meaningful heading
    2. 2Expanded state matches visible content
    3. 3Single or multiple expansion is intentional
    4. 4Opening and closing never moves focus unexpectedly

    Understand → Recognize → Choose → Compare

    Pack for your agent

    Pre-written instructions to paste into your agent. Copying executes nothing.

    Implement correctly

    Build Accordion without breaking its behavior

    # Implement Accordion in your agent
    
    ## Objective
    Implement Accordion for this verified behavior: A vertical set of headings that reveals or hides each associated content section.
    
    ## Prerequisites
    - Inspect the repository, design system, and existing tests first.
    - Preserve unrelated changes and keep the file scope bounded.
    - Confirm that Accordion matches the need before writing code.
    
    ## Required behavior
    - Activating a header reveals or hides its associated content while exposing expanded state.
    - Arrow keys move through related items according to their visual orientation.
    
    ## States to cover
    - Refunds collapsed
    - Refunds expanded
    
    ## Accessibility
    - ARIA role: heading > button[aria-expanded][aria-controls] + region
    - The primary control or named region for Accordion has a stable accessible name from visible text or an explicit programmatic label; placeholder text and tooltips are not names.
    - Focus remains on the header button when its panel opens or closes.
    - Each expanded panel closes by activating its own header when the product allows collapse.
    - Heading level, button name, expanded state, and controlled relationship are exposed.
    - Tab reaches every header button
    - Enter or Space toggles a section
    - Optional arrow keys move between headers
    
    ## When not to use
    - All content is short enough to show directly
    - The sections are primary destinations that need URLs
    
    ## Acceptance criteria
    - Every header is a real button inside a meaningful heading
    - Expanded state matches visible content
    - Single or multiple expansion is intentional
    - Opening and closing never moves focus unexpectedly
    
    ## Guardrails
    - Show the proposed changes before any external action.
    - Do not publish, send, delete, pay for, or change remote state without explicit authorization.
    - Preserve unrelated changes and stop if the scope becomes ambiguous.
    
    ## Output format
    - Outcome or verdict.
    - Files or actions involved.
    - Checks run and observable evidence.
    - Remaining blockers or limitations.
    
    • @radix-ui/react-accordion
    • Requires · Access to the repository, design system, and tests
    Why it works
    • The need is tied to canonical behavior before any technical choice.
    • States, accessibility, and non-goals prevent a merely visual implementation.
    • Acceptance criteria and the output format make verification observable.

    Try next

    Verify Accordion on a real journey

    # Verify Accordion after implementation
    
    ## Objective
    Audit the Accordion implementation against its behavior, states, and accessibility requirements without changing it automatically.
    
    ## Checks
    - Replay the smallest representative journey.
    - Check keyboard behavior, focus, accessible name, and announcements.
    - Tie each gap to a specific acceptance criterion.
    
    ## Guardrails
    - Show the proposed changes before any external action.
    - Do not publish, send, delete, pay for, or change remote state without explicit authorization.
    - Preserve unrelated changes and stop if the scope becomes ambiguous.
    
    ## Output format
    - Outcome or verdict.
    - Files or actions involved.
    - Checks run and observable evidence.
    - Remaining blockers or limitations.
    

    sha256:711280266c8e17e9d48287fea4e77abe16c58c9e6a89077fe44d728c8279ebe5

    Diagnose a problem

    Find and fix the Accordion defect

    # Debug Accordion in your agent
    
    ## Observed symptom
    [DESCRIBE THE SYMPTOM HERE]
    
    ## Observable checks
    - Reproduce the issue with the smallest relevant journey.
    - Compare behavior with the documented states and transitions for Accordion.
    - Verify keyboard behavior, focus, accessible name, and announcements.
    
    ## Possible causes
    - The chosen primitive does not match the expected behavior.
    - A state, transition, or focus return is missing.
    - A neighboring component captures an event or hides an accessible signal.
    
    ## Bounded corrections
    - Fix the reproduced cause without recreating neighboring components.
    - Preserve the public contract and add a focused regression test.
    - Do not install dependencies or change remote state without authorization.
    
    ## Final verification
    - Every header is a real button inside a meaningful heading
    - Expanded state matches visible content
    - Single or multiple expansion is intentional
    - Opening and closing never moves focus unexpectedly
    
    ## Guardrails
    - Show the proposed changes before any external action.
    - Do not publish, send, delete, pay for, or change remote state without explicit authorization.
    - Preserve unrelated changes and stop if the scope becomes ambiguous.
    
    ## Output format
    - Outcome or verdict.
    - Files or actions involved.
    - Checks run and observable evidence.
    - Remaining blockers or limitations.
    
    • @radix-ui/react-accordion
    • Requires · Access to the repository, design system, and tests
    Why it works
    • The explicit symptom prevents starting from an assumed fix.
    • Checks separate behavior, accessibility, and neighboring interference.
    • The fix stays bounded and must produce regression evidence.

    Try next

    Lock in the Accordion fix

    # Prevent the Accordion regression
    
    ## Objective
    Turn the reproduced cause into a focused regression test and compare Accordion with neighboring concepts before widening the fix.
    
    ## Checks
    - Prove that the test fails before the fix.
    - Prove that it passes after the bounded fix.
    - Verify that no neighboring component changed behavior.
    
    ## Guardrails
    - Show the proposed changes before any external action.
    - Do not publish, send, delete, pay for, or change remote state without explicit authorization.
    - Preserve unrelated changes and stop if the scope becomes ambiguous.
    
    ## Output format
    - Outcome or verdict.
    - Files or actions involved.
    - Checks run and observable evidence.
    - Remaining blockers or limitations.
    

    sha256:df782db7e0160f67416cc680ef434c412c728751af1eee481d2fa0e8bc8bb759

    Full entry, saving and provenance

    Pre-written instruction by SkillCodex — your request is neither sent nor used to adapt this text; no content is generated, and copying executes nothing.

    Pack digest: sha256:ec52190c96b951e99fbb6cfa25f4d689db4e540deee7698009bedf053e16fcc1

    In code

    TechnologyPrimitiveVersionCaveat
    @radix-ui/react-accordion

    Accordion.Root

    @radix-ui/react-accordion@1.2.16Radix supplies disclosure state and keyboard support; heading levels, expansion mode, and region use remain content decisions.

    Technical details

    Behaviors

    • Reveal and hide a section

      Activating a header reveals or hides its associated content while exposing expanded state.

    • Navigate with arrows

      Arrow keys move through related items according to their visual orientation.

    States

    • Refunds collapsed

      Refunds collapsed

    • Refunds expanded

      Refunds expanded

    State transitions

    • Refunds collapsed → Refunds expanded

      Activating the Refunds header exposes its answer immediately after the header.

    • Refunds expanded → Refunds collapsed

      Activating the expanded Refunds header hides only its associated answer.

    Test scenarios

    Context
    A billing help page groups answers for invoices, refunds, and payment methods.
    Mission
    Expand Refunds, move to Payment methods with keyboard, open it, and collapse Refunds again.
    Primary state
    The expanded header exposes its state and the answer appears immediately after it.
    Edge case
    A mandatory open section cannot be collapsed and communicates that rule without presenting a false control.

    Visual signals

    • Stacked headings with disclosure indicators
    • Content appears directly below its heading
    • Several sections may remain visible

    Behavioral signals

    • Header activation toggles expanded state
    • Tab reaches each header button
    • Single or multiple expansion is declared

    Accessibility

    Role
    heading > button[aria-expanded][aria-controls] + region
    Accessible name
    The primary control or named region for Accordion has a stable accessible name from visible text or an explicit programmatic label; placeholder text and tooltips are not names.
    Focus
    Focus remains on the header button when its panel opens or closes.
    Dismissal
    Each expanded panel closes by activating its own header when the product allows collapse.
    Scroll
    Expanding or collapsing content keeps the controlling header visible and avoids an unexpected page jump.
    Announcement
    Heading level, button name, expanded state, and controlled relationship are exposed.
    Keyboard
    • Tab reaches every header button
    • Enter or Space toggles a section
    • Optional arrow keys move between headers

    Bindings

    Open the HTML, ARIA, Radix, and shadcn matrix
    • Accordion.Root

      implementationKind
      radix
      nativeElement
      Not applicable
      ariaPattern
      disclosure buttons with aria-expanded
      radixPrimitive
      Accordion
      shadcnRecipe
      Accordion
      runtimeDependency
      @radix-ui/react-accordion@1.2.16
      packageName
      @radix-ui/react-accordion
      exportName
      Accordion.Root
      exactVersion
      1.2.16
      status
      verified
      sourceId
      source-ui-radix-accordion
      deprecationStatus
      active
      replacement
      Not applicable
      validFrom
      Not applicable
      validUntil
      Not applicable

      Equivalence caveat: Radix supplies disclosure state and keyboard support; heading levels, expansion mode, and region use remain content decisions.

      Verify binding source

    Sources

    • WAI-ARIA APG: Accordion Pattern
      sourceId
      source-ui-aria-accordion
      kind
      documentation
      canonicalUrl
      https://www.w3.org/WAI/ARIA/apg/patterns/accordion/
      publisher
      W3C WAI
      sourceRevision
      http-last-modified:2026-07-09T07:07:36Z
      consultedAt
      2026-07-19
      license
      Not stated
      contentDigest
      sha256:d66381c3684cfb78744d5648cb7f567387d6d0f5f07d842953e27f23541f5ae7
      status
      verified

      Claim covered: Accordion: informative APG guidance for the accordion pattern: roles, states, relationships, and keyboard interaction.

    • Radix Primitives: Accordion
      sourceId
      source-ui-radix-accordion
      kind
      documentation
      canonicalUrl
      https://www.radix-ui.com/primitives/docs/components/accordion
      publisher
      Radix Primitives
      sourceRevision
      http-etag:W/"c0cd83d6d0705b1dad9c207456ffd978"
      consultedAt
      2026-07-19
      license
      Not stated
      contentDigest
      sha256:3baef4674c46481d3c573a6dcd76c5a892d81d1618000af491013aa4484bca48
      status
      verified

      Claim covered: Accordion: documented parts, state APIs, interaction behavior, and implementation limits for Radix Accordion.

    • WAI-ARIA APG: Button Pattern
      sourceId
      source-ui-aria-button
      kind
      documentation
      canonicalUrl
      https://www.w3.org/WAI/ARIA/apg/patterns/button/
      publisher
      W3C WAI
      sourceRevision
      http-last-modified:2026-07-09T07:07:36Z
      consultedAt
      2026-07-19
      license
      Not stated
      contentDigest
      sha256:863329ea659a53439b0953eec0bd0af7c6219e372d0e878f75e57d263924704c
      status
      verified

      Claim covered: Accordion: informative APG guidance for the button pattern: roles, states, relationships, and keyboard interaction.

    • WAI-ARIA 1.2: Roles Model
      sourceId
      source-ui-wai-aria-roles
      kind
      standard
      canonicalUrl
      https://www.w3.org/TR/wai-aria-1.2/#roles
      publisher
      W3C WAI
      sourceRevision
      W3C-REC-wai-aria-1.2-20230606
      consultedAt
      2026-07-19
      license
      Not stated
      contentDigest
      sha256:c0fea16fc747779569ab754d2d25bca3e2b7e8a673b8ef5362aeb9ebc73a4849
      status
      verified

      Claim covered: Accordion: normative ARIA role definitions and constraints for the stated accessible role.

    • WCAG 2.2: Focus Appearance
      sourceId
      source-ui-wcag-understanding-focus-appearance
      kind
      documentation
      canonicalUrl
      https://www.w3.org/WAI/WCAG22/Understanding/focus-appearance.html
      publisher
      W3C WAI
      sourceRevision
      http-last-modified:2026-07-02T10:07:49Z
      consultedAt
      2026-07-19
      license
      Not stated
      contentDigest
      sha256:fdcf316a1f0e3cc758eda9618322d132862124ff0a3f3b1a3acbf20daf804ff0
      status
      verified

      Claim covered: Accordion: informative WCAG guidance for evaluating visible keyboard focus appearance.