A vertically stacked set of interactive headings that each reveal a section of content.
Loading...
Installation
Install the following dependencies:
Copy and paste the following code into your project.
Loading...
Update the import paths to match your project setup.
Composition
<app-accordion> └── <app-accordion-item> ├── <app-accordion-trigger> │ └── <app-accordion-item-indicator> (optional) └── <app-accordion-content>
Examples
Card
Loading...
Controlled
Loading...
Default
Loading...
Separated Items
Loading...
With Form Fields
Loading...
With Icons
Loading...
API Reference
<app-accordion>
Inputs
| Input | Type | Default | Description |
|---|---|---|---|
id | string | undefined | generated | Unique identifier used to create the accordion part IDs. |
ids | AccordionElementIds | undefined | — | Overrides the generated IDs for individual parts. |
value | string[] | undefined | — | Expanded item values when controlled. Supports Angular two-way binding. |
defaultValue | string[] | undefined | — | Initially expanded item values when uncontrolled. |
multiple | boolean | false | Allows more than one item to be expanded. |
collapsible | boolean | false | Allows every item to be collapsed. |
disabled | boolean | false | Disables interaction with every item. |
orientation | "horizontal" | "vertical" | undefined | "vertical" | Sets the accordion orientation and keyboard navigation axis. |
lazyMount | boolean | false | Mounts an item's content only after the item is first expanded. |
unmountOnExit | boolean | false | Removes an item's content from the DOM when the item is collapsed. |
Use [(value)]="value" for two-way binding, or combine [value] with (valueChange) when using signals.
Outputs
| Output | Type | Description |
|---|---|---|
valueChange | string[] | undefined | Emits the updated array of expanded values. |
focusChange | AccordionFocusChangeDetails | Emits when the focused accordion item changes. |
<app-accordion-item>
Inputs
| Input | Type | Default | Description |
|---|---|---|---|
value | string | required | Unique value that identifies the item. |
disabled | boolean | false | Prevents the item from being expanded. |
Context, Providers, and Utilities
| Export | Angular API |
|---|---|
AccordionRootProvider | Directive that provides an externally created accordion API through value. |
AccordionContext | Structural directive [accordion-context] exposing the root API to a template. |
AccordionItemContextDirective | Structural directive [accordion-item-context] exposing the current item state. |
useAccordion(options) | Creates the signal-backed accordion machine inside an Angular injection context. |
injectAccordionContext() | Injects the nearest root accordion context. |
injectAccordionItemContext() | Injects the nearest accordion item context. |
Types
| Export | Description |
|---|---|
AccordionApi | Connected accordion state and actions. |
AccordionElementIds | Overrides for generated accordion part IDs. |
AccordionFocusChangeDetails | Details emitted by focusChange. |
AccordionValueChangeDetails | Details produced by the underlying state machine. |
Angular
React
Solid
Svelte
Vue