<vega-accordion
draws-background="false"
accordion-title="Accordion Title"
expand-icon-align="left"
expand="false"
group-id="group-id"
>
<div slot="title">This is the title</div>
<div slot="content">Accordion content</div>
</vega-accordion>
<vega-accordion
draws-background="false"
accordion-title="Accordion Title"
expand-icon-align="right"
expand="false"
group-id="group-id"
>
<div slot="title">This is the title</div>
<div slot="content">Accordion content</div>
</vega-accordion>
Accordions, also known as expansion panels or collapsible panels, are used to aid usability for pages which contain large amounts of content. They enable creation of elements on a page where one can place sections of content which can be shown or hidden by clicking on a button which expands or contracts the page.
Common places where Accordions may be used include:
Accordions have two states:
There are also some states for the chevron icon. When in active or hover state, a circle appears over the chevron.
Name | Description | Default |
---|---|---|
draws-background | Boolean indicating whether or not the accordion block should have a background color rgba(252, 252, 252, 1) and a padding of v-size-24 . boolean |
false |
prefix-icon | set the prefix icon of accordion. string | - |
accordion-title | set the title of accordion. string | - |
expand-icon-align | set the placement of accordion expand icon. string | right |
expand | set the state of accordion. boolean | true |
group-id | If you want have only one accordion function (to have all accordion frames expand at the same time), set a group id. string | - |
show-expand-icon | This specifies whether to display or hide the expand icon. It can be set as ResponsiveType or boolean - | - |
icon-position | Sets the vertical position of the icon | top |
<vega-accordion
draws-background: true|false,
prefix-icon: Icons,
accordion-title: 'Accordion Title',
expand-icon-align: 'left'|'right',
expand: true|false,
group-id: 'group-id',
>
<div slot='title'>Accordion title</div>
<div slot='content'>Accordion content</div>
Child Elements
</vega-accordion>
For more details, view in Storybook.
In order to make accordions accessible, it’s considered best practice to toggle several ARIA properties and states, specifically aria-hidden
and aria-expanded
.
The following criteria are also required.
One known problem with accordions is that if they are closed, this requires users to click on items one at a time to open them, which increases the interaction cost. In general, users are more likely to scroll than to open individual accordion items.
In many situations, it is better to provide static content on a page; this not only increases the likelihood that content can be read without excess interaction, it makes it easier for users who choose to search for content on a page.
Also, accessibility should be a major consideration for your site. It is important to ensure that all components of the accordion are encoded with accessibility in mind. Note: Vega accordions are built to handle these use cases.
For this reason, before using accordions it is best to consider the individual use case.
Reasons to avoid using accordions can include the following:
Reasons for using accordions can include the following: