Skip to main content
Logo USWDS + Tailwind

Accordion

An accordion is a list of headers that hide or reveal additional content when selected.

This component requires the following JavaScript plugin:

Examples

Default

Breakpoints

Mobile

320px

Mobile Lg

480px

Tablet

640px

Desktop

1024px

Congress shall make no law respecting an establishment of religion, or prohibiting the free exercise thereof; or abridging the freedom of speech, or of the press; or the right of the people peaceably to assemble, and to petition the Government for a redress of grievances.

A well regulated Militia, being necessary to the security of a free State, the right of the people to keep and bear Arms, shall not be infringed.

No Soldier shall, in time of peace be quartered in any house, without the consent of the Owner, nor in time of war, but in a manner to be prescribed by law.

The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no Warrants shall issue, but upon probable cause, supported by Oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized.

No person shall be held to answer for a capital, or otherwise infamous crime, unless on a presentment or indictment of a Grand Jury, except in cases arising in the land or naval forces, or in the Militia, when in actual service in time of War or public danger; nor shall any person be subject for the same offence to be twice put in jeopardy of life or limb; nor shall be compelled in any criminal case to be a witness against himself, nor be deprived of life, liberty, or property, without due process of law; nor shall private property be taken for public use, without just compensation.

Twig
<div
x-accordion
class="space-y-2"
>
{% for accordion in accordions %}
<div x-accordion:item>
<h4 class="relative">
<button
x-accordion:trigger
class="group flex items-center w-full py-4 px-5 bg-gray-5 hover:bg-gray-10 font-bold focus:outline focus:outline-4 focus:outline-blue-40v cursor-pointer text-left gap-3"
>
{{- accordion.title -}}
<div class="h-full flex items-center ml-auto shrink-0">
<div
class="size-6 icon-[material-symbols--add] group-aria-expanded:icon-[material-symbols--remove]"
></div>
</div>
</button>
</h4>
<div
x-cloak
x-accordion:content
class="py-6 px-4 [&[hidden]]:p-0"
>
<p class="leading-normal max-w-prose">
{{- accordion.content -}}
</p>
</div>
</div>
{% endfor %}
</div>

Multiselectable

Breakpoints

Mobile

320px

Mobile Lg

480px

Tablet

640px

Desktop

1024px

Congress shall make no law respecting an establishment of religion, or prohibiting the free exercise thereof; or abridging the freedom of speech, or of the press; or the right of the people peaceably to assemble, and to petition the Government for a redress of grievances.

A well regulated Militia, being necessary to the security of a free State, the right of the people to keep and bear Arms, shall not be infringed.

No Soldier shall, in time of peace be quartered in any house, without the consent of the Owner, nor in time of war, but in a manner to be prescribed by law.

The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no Warrants shall issue, but upon probable cause, supported by Oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized.

No person shall be held to answer for a capital, or otherwise infamous crime, unless on a presentment or indictment of a Grand Jury, except in cases arising in the land or naval forces, or in the Militia, when in actual service in time of War or public danger; nor shall any person be subject for the same offence to be twice put in jeopardy of life or limb; nor shall be compelled in any criminal case to be a witness against himself, nor be deprived of life, liberty, or property, without due process of law; nor shall private property be taken for public use, without just compensation.

Twig
<div
x-accordion
class="space-y-2"
data-multiple
>
{% for accordion in accordions %}
<div x-accordion:item>
<h4 class="relative">
<button
x-accordion:trigger
class="group flex items-center w-full py-4 px-5 bg-gray-5 hover:bg-gray-10 font-bold focus:outline focus:outline-4 focus:outline-blue-40v cursor-pointer text-left gap-3"
>
{{- accordion.title -}}
<div class="h-full flex items-center ml-auto shrink-0">
<div
class="size-6 icon-[material-symbols--add] group-aria-expanded:icon-[material-symbols--remove]"
></div>
</div>
</button>
</h4>
<div
x-cloak
x-accordion:content
class="py-6 px-4 [&[hidden]]:p-0"
>
<p class="leading-normal max-w-prose">
{{- accordion.content -}}
</p>
</div>
</div>
{% endfor %}
</div>

Bordered

Breakpoints

Mobile

320px

Mobile Lg

480px

Tablet

640px

Desktop

1024px

Congress shall make no law respecting an establishment of religion, or prohibiting the free exercise thereof; or abridging the freedom of speech, or of the press; or the right of the people peaceably to assemble, and to petition the Government for a redress of grievances.

A well regulated Militia, being necessary to the security of a free State, the right of the people to keep and bear Arms, shall not be infringed.

No Soldier shall, in time of peace be quartered in any house, without the consent of the Owner, nor in time of war, but in a manner to be prescribed by law.

The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no Warrants shall issue, but upon probable cause, supported by Oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized.

No person shall be held to answer for a capital, or otherwise infamous crime, unless on a presentment or indictment of a Grand Jury, except in cases arising in the land or naval forces, or in the Militia, when in actual service in time of War or public danger; nor shall any person be subject for the same offence to be twice put in jeopardy of life or limb; nor shall be compelled in any criminal case to be a witness against himself, nor be deprived of life, liberty, or property, without due process of law; nor shall private property be taken for public use, without just compensation.

Twig
<div
x-accordion
class="space-y-2"
data-multiple
>
{% for accordion in accordions %}
<div x-accordion:item>
<h4 class="relative">
<button
x-accordion:trigger
class="group flex items-center w-full py-4 px-5 bg-gray-5 hover:bg-gray-10 font-bold focus:outline focus:outline-4 focus:outline-blue-40v cursor-pointer text-left gap-3"
>
{{- accordion.title -}}
<div class="h-full flex items-center ml-auto shrink-0">
<div
class="size-6 icon-[material-symbols--add] group-aria-expanded:icon-[material-symbols--remove]"
></div>
</div>
</button>
</h4>
<div
x-cloak
x-accordion:content
class="py-6 px-4 [&[hidden]]:p-0 border-b-4 border-x-4 border-gray-5"
>
<p class="leading-normal max-w-prose">
{{- accordion.content -}}
</p>
</div>
</div>
{% endfor %}
</div>

Component API

Accordions are made up of 4 primary elements:

Root

  • x-accordion

    Custom Alpine directive that marks the Accordion Root.

Item

  • x-accordion:item

    Custom Alpine directive that marks a single Accordion Item.

Trigger

  • x-accordion:trigger

    Custom Alpine directive that marks the Accordion Trigger.

  • aria-controls

    Type: string

    Accessibility attribute that links the Accordion Trigger control to it’s respective Accordion Content.

    Automatically handled with JavaScript.

  • aria-expanded

    Type: boolean

    Accessibility attribute that communicates whether an element is expanded or collapsed.

    Automatically handled with JavaScript.

Content

  • x-accordion:content

    Custom Alpine directive that marks the Accordion Content.

  • id

    Type: string

    Links the Accordion Content to it’s respective Accordion Trigger.

    Automatically handled with JavaScript.

  • hidden

    Type: 'until-found' | false

    Handles the visibility of the Accordion Content. When until-found, content will be hidden but discoverable to browser search. When false, content will be visible and hidden attribute will be removed.

    Automatically handled with JavaScript.

Keyboard Interactions

  • Enter or Space

    When focus is on an Accordion Item for a collapsed panel, expands the associated panel. If the implementation allows only one panel to be expanded, the previously expanded panel is collapsed.

  • Tab

    Moves focus to the next focusable element. All Accordion Items in the Accordion List must be included in the page Tab sequence.

  • Down Arrow

    If focus is on an Accordion Item, moves focus to the next Accordion Item. If focus is on the last Accordion Item, moves focus to the first Accordion Item.

  • Shift + Tab

    Moves focus to the previous focusable element. All Accordion Items in the Accordion List must be included in the page Tab sequence.

  • Up Arrow

    If focus is on an Accordion Item, moves focus to the previous Accordion Item. If focus is on the first Accordion Item, moves focus to the last Accordion Item.

  • Home or fn + Left Arrow (Mac)

    If focus is on an Accordion Item, moves focus to the first Accordion Item.

  • End or fn + Right Arrow (Mac)

    If focus is on an Accordion Item, moves focus to the last Accordion Item.