The `<sp-accordion>` element contains a list of items that can be expanded or collapsed to reveal additional content or information associated with each item. There can be zero expanded items, exactly one expanded item, or more than one item expanded at a
npm install @spectrum-web-components/accordionThe element contains a list of items that can be expanded or collapsed to reveal additional content or information associated with each item. There can be zero expanded items, exactly one expanded item, or more than one item expanded at a time, depending on the configuration. This list of items is defined by child elements that are targeted to the default slot of their parent.



``bash`
yarn add @spectrum-web-components/accordion
Import the side effectful registration of and via:
`js`
import '@spectrum-web-components/accordion/sp-accordion.js';
import '@spectrum-web-components/accordion/sp-accordion-item.js';
When looking to leverage the Accordion and AccordionItem base class as a type and/or for extension purposes, do so via:
`js`
import { Accordion, AccordionItem } from '@spectrum-web-components/accordion';
The accordion consists of several key parts:
- A container element that manages the accordion behavior
- Individual accordion items that can be expanded or collapsed
- Each item has a header with a label and chevron icon
- Content that is revealed when an item is expanded
`html`
The bellows is the expandable section in the middle of the
accordion.
The treble section of the accordion is the right-hand section for
playing melodies.
The bass section of the accordion is the left-hand section for
playing accompaniment.
#### Sizes
`html`
A key accordion, or a chromatic piano accordion, includes a keyboard
for the right hand.
A button accoridon, or a chromatic accordion, has buttons instead of
keys.
Produces two different tones or notes depending on whether the
bellows is pulled or pushed.
A concertina has buttons on both sides and each button makes two
different notes or tones depending on whether the bellows is pulled
or pushed.
`html`
A key accordion, or a chromatic piano accordion, includes a keyboard
for the right hand.
A button accoridon, or a chromatic accordion, has buttons instead of
keys.
Produces two different tones or notes depending on whether the
bellows is pulled or pushed.
A concertina has buttons on both sides and each button makes two
different notes or tones depending on whether the bellows is pulled
or pushed.
`html`
A key accordion, or a chromatic piano accordion, includes a keyboard
for the right hand.
A button accoridon, or a chromatic accordion, has buttons instead of
keys.
Produces two different tones or notes depending on whether the
bellows is pulled or pushed.
A concertina has buttons on both sides and each button makes two
different notes or tones depending on whether the bellows is pulled
or pushed.
`html`
A key accordion, or a chromatic piano accordion, includes a keyboard
for the right hand.
A button accoridon, or a chromatic accordion, has buttons instead of
keys.
Produces two different tones or notes depending on whether the
bellows is pulled or pushed.
A concertina has buttons on both sides and each button makes two
different notes or tones depending on whether the bellows is pulled
or pushed.
#### Density
The density property, when applied, accepts the values of compact or spacious.
`html
style="
display: grid;
grid-gap: 20px;
grid-template-columns: 1fr 1fr"
>
This accordion is compact.
This accordion is also small.
This accordion is compact.
This accordion is also medium.
This accordion is compact.
This accordion is also large.
This accordion is compact.
This accordion is also extra large.
Spacious
`html
style="
display: grid;
grid-gap: 20px;
grid-template-columns: 1fr 1fr"
>
This accordion is spacious.
This accordion is also small.
This accordion is spacious.
This accordion is also medium.
This accordion is spacious.
This accordion is also large.
This accordion is spacious.
This accordion is also extra large.
$3
#### Allow Multiple
By default, only one accordion item can be expanded at a time. Use the
allow-multiple attribute to allow multiple items to be expanded simultaneously.`html
Kermit is a frog.
Fozzie is a bear.
Miss Piggy is a pig.
`#### Disabled
Individual accordion items can be disabled using the
disabled attribute. Disabled items cannot be expanded or collapsed.`html
We have some of the most popular varieties include Red Delicious,
Gala, Granny Smith, Honeycrisp, and Fuji.
We have the Gros Michel.
We have Mandarins, Seville Oranges, and Clementines.
`$3
The accordion component provides proper ARIA attributes and keyboard navigation:
- Each accordion item header has
aria-expanded to indicate its current state
- The header button has aria-controls pointing to the content region
- The content region has role="region" and aria-labelledby pointing to the header
- Disabled items have aria-disabled="true"` applied#### Include descriptive labels
Each accordion item should have a clear, descriptive label that indicates what content will be revealed when expanded.
#### Use appropriate content
Accordion content should be related to the header label and provide additional information or functionality that users can access when needed.