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="amendment-1">
            First Amendment
          </button>
          <div id="amendment-1" class="usa-accordion-content">
            <p>
            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.
            </p>
          </div>
        </li>
        <li>
          <button class="usa-accordion-button"
            aria-controls="amendment-2">
            Second Amendment
          </button>
          <div id="amendment-2" class="usa-accordion-content">
            <p>
            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.
            </p>
          </div>
        </li>
        <li>
          <button class="usa-accordion-button"
              aria-controls="amendment-3">
            Third Amendment
          </button>
          <div id="amendment-3" class="usa-accordion-content">
            <p>
            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.
            </p>
          </div>
        </li>
        <li>
          <button class="usa-accordion-button"
            aria-controls="amendment-4">
            Fourth Amendment
          </button>
          <div id="amendment-4" class="usa-accordion-content">
            <p>
            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.
            </p>
          </div>
        </li>
        <li>
          <button class="usa-accordion-button"
            aria-controls="amendment-5">
            Fifth Amendment
          </button>
          <div id="amendment-5" class="usa-accordion-content">
            <p>
            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.
            </p>
          </div>
        </li>
      </ul>
    
      <h6>Bordered</h6>
    
      <ul class="usa-accordion-bordered">
        <li>
          <button class="usa-accordion-button"
            aria-expanded="true" aria-controls="amendment-b-1">
            First Amendment
          </button>
          <div id="amendment-b-1" class="usa-accordion-content">
            <p>
            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.
            </p>
          </div>
        </li>
        <li>
          <button class="usa-accordion-button"
            aria-controls="amendment-b-2">
            Second Amendment
          </button>
          <div id="amendment-b-2" class="usa-accordion-content">
            <p>
            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.
            </p>
          </div>
        </li>
        <li>
          <button class="usa-accordion-button"
              aria-controls="amendment-b-3">
            Third Amendment
          </button>
          <div id="amendment-b-3" class="usa-accordion-content">
            <p>
            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.
            </p>
          </div>
        </li>
        <li>
          <button class="usa-accordion-button"
            aria-controls="amendment-b-4">
            Fourth Amendment
          </button>
          <div id="amendment-b-4" class="usa-accordion-content">
            <p>
            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.
            </p>
          </div>
        </li>
        <li>
          <button class="usa-accordion-button"
            aria-controls="amendment-b-5">
            Fifth Amendment
          </button>
          <div id="amendment-b-5" class="usa-accordion-content">
            <p>
            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.
            </p>
          </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.)

Upgrading deprecated accordions

The accordion was changed July 2016 in order to improve its implementation. Currently, both versions of the accordion work, but at some point in the future, the deprecated accordion will no longer function correctly. To upgrade your existing accordions to the new accordion:

  • Remove the top level div that contains the usa-accordion or usa-accordion-bordered class.
  • Add the usa-accordion or usa-accordion-bordered class to the ul element that's now at the top level.

Deprecated

The following accordion has been deprecated since July 2016. Please follow the instructions to update any existing accordions to the new format.

Deprecated
  • 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.