Live demo
Demo source
Use an accordion to split related content into sections that people open when they need them, such as questions and answers or settings groups. Keep content that everyone needs visible instead of hiding it in a section.
Anatomy
An open accordion item with three callouts: 1 marks the item, 2 the header with its title and chevron, and 3 the panel with the content.
- Item (
nv-accordion-item) is one section of the accordion. - Header shows
itemTitleand an optionalsubtitle, or your own content in theheaderslot. The chevron opens and closes the section. - Panel holds the
contentslot.
Opening sections
mode="accordion" (the default) keeps one section open at a time;
mode="multi" lets several stay open. The design calls these settings
"singleExpand" and "isOpen": in the API, set open on an item, or control the
whole accordion with openIndexes and its openIndexesChanged event.
disabled keeps an item closed.
The open, closed and disabled states use the current Spark or Ocean theme. The header stays visible when the panel closes. Both header and panel content can be replaced through the item's slots.
| Design setting | Component API |
|---|---|
| Is open | open on nv-accordion-item |
| Single expand | mode="accordion" on the parent; use mode="multi" for several open panels |
| Custom header | header slot on the item |
| Custom panel | content slot on the item |
Content and accessibility
Use a single semantic heading at the right level for the page in the header
slot when the section needs one, such as <h3 slot="header">Delivery</h3>.
The built-in itemTitle renders a span, so it does not create a heading by
itself. Avoid nesting headings inside each other.
- Keep titles short so people can scan the sections.
- Keep each panel focused on one topic.
- The chevron is keyboard operable; preserve its focus indicator when styling custom header content.
The design guidance mentions warning variants, but this component has no feedback or warning prop. Put an alert in the panel when its content needs that treatment.