Primitives
A collapsible shows and hides an associated section of content, following the WAI-ARIA disclosure pattern.
Import the Collapsible primitives from ng-primitives/collapsible.
import {
NgpCollapsible,
NgpCollapsibleTrigger,
NgpCollapsibleContent,
} from 'ng-primitives/collapsible';
Assemble the collapsible directives in your template.
<div ngpCollapsible>
<button ngpCollapsibleTrigger>Show details</button>
<div ngpCollapsibleContent>The content that is shown and hidden.</div>
</div>
For a single collapsible, use this primitive directly. If you need multiple sections with coordinated open state - where opening one may close another - reach for the Accordion primitive instead. Each accordion item is built on this same collapsible core.
The following directives are available to import from the ng-primitives/collapsible package:
The ngpCollapsibleContent primitive sets --ngp-collapsible-content-width and --ngp-collapsible-content-height CSS custom properties on the element. Use these with the data-enter and data-exit attributes to animate open and close. These attributes are only set on user interaction - not on initial render - so no animation plays on page load.
Adheres to the Disclosure WAI-ARIA design pattern.
The trigger exposes aria-expanded and aria-controls, pointing at the content region. When the trigger is a <button> element the correct type="button" is applied automatically.
The ngpCollapsibleContent primitive uses the until-found attribute so the browser can search text within the collapsed region and reveal it if a match is found. If the browser does not support this functionality, the attribute is ignored.
More information about the until-found attribute can be found on Can I use.
Copyright © 2026 Angular Primitives
This site is powered by Netlify