UI components

Accordions

Accordions are a list of headers that can be clicked to hide or reveal additional content.

Borderless
  • 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.
Bordered
  • 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.
<h6>Borderless</h6>

<ul class="usa-accordion">
  <li>
    <button
      class="usa-accordion-button"
      aria-expanded="true"
      aria-controls="a1"
    >
      First Amendment
    </button>
    <div id="a1" class="usa-accordion-content">
      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.
    </div>
  </li>
  <li>
    <button
      class="usa-accordion-button"
      aria-expanded="false"
      aria-controls="a2"
    >
      Second Amendment
    </button>
    <div id="a2" class="usa-accordion-content">
      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.
    </div>
  </li>
  <li>
    <button
      class="usa-accordion-button"
      aria-expanded="false"
      aria-controls="a3"
    >
      Third Amendment
    </button>
    <div id="a3" class="usa-accordion-content">
      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.
    </div>
  </li>
  <li>
    <button
      class="usa-accordion-button"
      aria-expanded="false"
      aria-controls="a4"
    >
      Fourth Amendment
    </button>
    <div id="a4" class="usa-accordion-content">
      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.
    </div>
  </li>
  <li>
    <button
      class="usa-accordion-button"
      aria-expanded="false"
      aria-controls="a5"
    >
      Fifth Amendment
    </button>
    <div id="a5" class="usa-accordion-content">
      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.
    </div>
  </li>
</ul>

<h6>Bordered</h6>

<ul class="usa-accordion-bordered">
  <li>
    <button
      class="usa-accordion-button"
      aria-expanded="true"
      aria-controls="b-a1"
    >
      First Amendment
    </button>
    <div id="b-a1" class="usa-accordion-content">
      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.
    </div>
  </li>
  <li>
    <button
      class="usa-accordion-button"
      aria-expanded="false"
      aria-controls="b-a2"
    >
      Second Amendment
    </button>
    <div id="b-a2" class="usa-accordion-content">
      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.
    </div>
  </li>
  <li>
    <button
      class="usa-accordion-button"
      aria-expanded="false"
      aria-controls="b-a3"
    >
      Third Amendment
    </button>
    <div id="b-a3" class="usa-accordion-content">
      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.
    </div>
  </li>
  <li>
    <button
      class="usa-accordion-button"
      aria-expanded="false"
      aria-controls="b-a4"
    >
      Fourth Amendment
    </button>
    <div id="b-a4" class="usa-accordion-content">
      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.
    </div>
  </li>
  <li>
    <button
      class="usa-accordion-button"
      aria-expanded="false"
      aria-controls="b-a5"
    >
      Fifth Amendment
    </button>
    <div id="b-a5" class="usa-accordion-content">
      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.
    </div>
  </li>
</ul>

Accessibility

  • Code header areas in the accordion as <buttons> so that they are usable with both screen readers and the keyboard.
  • Buttons should state if they are expanded with aria-expanded="true". The aria-expanded="false" attributes will be added to other buttons when the accordion is initialized by the JavaScript.
  • Each button has a unique name aria-controls="id" that associates the control to the appropriate region by referencing the controlled element’s id.
  • Each content area will have its aria-hidden attribute set to either true or false by the component, depending on its corresponding button’s aria-expanded attribute. To ensure that your content is accessible in the event that the JavaScript does not load or is disabled, you should not set aria-hidden="true" on any of your content areas.

Usability

When to use
  • Users only need a few specific pieces of content within a page.
  • Information needs to be displayed in a small space.
When to consider something else
  • If visitors need to see most or all of the information on a page. Use well-formatted text instead.
  • If there is not enough content to warrant condensing. Accordions increase cognitive load and interaction cost, as users have to make decisions about what headers to click on.
Guidance
  • Allow users to click anywhere in the header area to expand or collapse the content; a larger target is easier to manipulate.
  • Make sure interactive elements within the collapsible region are far enough from the headers that users don’t accidentally trigger a collapse. (The exact distance depends on the device.)