Accordion

Stacked sections that each show or hide their content. Use it to shorten long pages such as FAQs or settings, where readers only need a few sections at a time.

  • vig-accordion
  • vig-accordion-item
  • [vigAccordionHeader]
Import
import { Accordion, AccordionItem, AccordionHeader } from '@vigdx/ui/accordion';

Basic

Each vig-accordion-item needs a unique value and a heading ; the projected content is its panel. By default opening one item closes the others.

Multiple open items

multiple lets several items stay open. [(value)] holds the values of the open items, so you can preset them or open and close all of them from outside.

The park opens on 1 April and closes on 31 October.

Weekdays 10:00–18:00, weekends 09:00–20:00.

Open: season, hours

Custom header and disabled

An ng-template vigAccordionHeader inside an item replaces the text header, e.g. with an icon and a badge. disabled items cannot be toggled and are skipped by the arrow keys. headingLevel (2–6, default 3) fits the headers into the page outline.

Styling hooks

Internal elements carry a stable data-part and the component's data-scope; both are public API, so removing one is a breaking change. Select a part by both, e.g. [data-scope="accordion"][data-part="heading"] { … }: the pair stays within this component when kit components nest, and also reaches parts in overlay panels, which render outside the host. State is exposed through aria-* and, where listed, a data-state; literal values are checked by the API gate, values computed from the component's state follow its documented types. Other data-* attributes listed below (such as data-opening while an overlay animates) are API too. See Customizing.

Scope: [data-scope="accordion"]

AccordionItem styling hooks
Part Element data-state
heading The h2 – h6 wrapping the trigger. —
trigger The header button ( aria-expanded ). open, closed
label The header text or template. —
indicator The chevron. —
panel The collapsible panel. open, closed
body The padded panel content. —

Accessibility

  • Follows the WAI-ARIA APG accordion pattern: each header is a <button> inside a native <h2>–<h6> heading whose level headingLevel sets. Pick the level that fits the surrounding headings.
  • Header buttons carry aria-expanded and aria-controls. Panels are not wrapped in per-item region landmarks, which would only add navigation noise; screen-reader users move between items by heading.
  • Enter and Space toggle an item, and Tab moves between headers like any other buttons. Arrow keys, Home and End are deliberately not intercepted: they scroll the page, which long panels need.
  • Closed panels stay in the DOM with hidden="until-found": they are skipped by screen readers and the tab order until opened and form fields inside keep their state, but the browser's find-in-page and text-fragment links can reveal their text, which opens the item. Where until-found is not supported they are simply hidden; panels of disabled items are never searchable.
  • A custom vigAccordionHeader template sits inside the button: keep it to non-interactive content (text, icons, badges).

API

Accordion

vig-accordion component

Vertically stacked disclosure sections: each header is a button inside a heading (so screen-reader users can move between items by heading), and Tab moves between headers like any other buttons — arrow keys are left to scrolling. Closed panels stay in the DOM as hidden="until-found", so find-in-page and text-fragment links can reveal them, which opens the item; browsers without until-found treat them as plain hidden.

Example :
<vig-accordion [(value)]="open" [multiple]="true">
  <vig-accordion-item value="season" heading="Season">…panel…</vig-accordion-item>
</vig-accordion>
Accordion props
Name Type Default Description
headingLevelAccordionHeadingLevel3

Level of the h2–h6 heading wrapping every header button.

multiplebooleanfalse

Allow several items open at once; otherwise opening one closes the rest.

value model readonly string[][]

Values of the open items; two-way bindable.

AccordionItem

vig-accordion-item component

One accordion section: value identifies it, heading (or a vigAccordionHeader template) names it, and the projected content is the panel.

AccordionItem props
Name Type Default Description
disabledbooleanfalse
—
headerstring''

Deprecated: Use `heading`; still honored when `heading` is unset.

—
headingstring | undefinedundefined

Header text; use a vigAccordionHeader template for richer content.

value required string—
—

Templates and directives

Templates and directives
Selector Export Description
[vigAccordionHeader]AccordionHeader

Marks an ng-template as an accordion item's custom header content.

Are you sure?