Accordion
vig-accordion vig-accordion-item [vigAccordionHeader]
import { Accordion, AccordionItem, AccordionHeader } from '@vigdx/ui/accordion';Basic
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.
Open: season, hours
Custom header and disabled
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"]
| Part | Element | data-state |
|---|---|---|
heading | h2 – h6 wrapping the trigger. | — |
trigger | aria-expanded ). | open, closed |
label | — | |
indicator | — | |
panel | open, closed | |
body | — |
Accessibility
- Follows the WAI-ARIA APG accordion pattern: each header is a
<button>inside a native<h2>–<h6>heading whose levelheadingLevelsets. Pick the level that fits the surrounding headings. - Header buttons carry
aria-expandedandaria-controls. Panels are not wrapped in per-itemregionlandmarks, 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. Whereuntil-foundis not supported they are simply hidden; panels of disabled items are never searchable. - A custom
vigAccordionHeadertemplate sits inside the button: keep it to non-interactive content (text, icons, badges).
API
Accordion
vig-accordionVertically 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.
<vig-accordion [(value)]="open" [multiple]="true">
<vig-accordion-item value="season" heading="Season">…panel…</vig-accordion-item>
</vig-accordion>| Name | Type | Default | Description |
|---|---|---|---|
headingLevel | AccordionHeadingLevel | 3 | Level of the |
multiple | boolean | false | Allow several items open at once; otherwise opening one closes the rest. |
value | readonly string[] | [] | Values of the open items; two-way bindable. |
| Name | Payload | Description |
|---|---|---|
valueChange | readonly string[] | Values of the open items; two-way bindable. |
| Signature | Description |
|---|---|
expand(value: string): void | Opens an item (no-op when already open). |
isOpen(value: string): boolean | — |
toggle(value: string): void | — |
AccordionItem
vig-accordion-itemOne accordion section: value identifies it, heading (or a
vigAccordionHeader template) names it, and the projected content is the
panel.
| Name | Type | Default | Description |
|---|---|---|---|
disabled | boolean | false | — |
header | string | '' | Deprecated: Use `heading`; still honored when `heading` is unset. — |
heading | string | undefined | undefined | Header text; use a |
value | string | — | — |
Templates and directives
| Selector | Export | Description |
|---|---|---|
[vigAccordionHeader] | AccordionHeader | Marks an ng-template as an accordion item's custom header content. |