Standard
Basic collapsible panels with toggle controls for size, card view, and always-open mode
Overview of the service and how to begin your application.
Documents and eligibility criteria needed before applying.
Fee schedule and expected processing times.
With Leading Icons
Add icons before each title for visual context and faster scanning
Browse housing programs and check eligibility.
Scholarships, transcripts, and certification exams.
Registration renewal, fines, and driving tests.
Built-in Features
Activates when .nds-accordion is on the page. No JavaScript setup required.
CSS grid transitions with automatic fallback when users prefer reduced motion.
Arrow keys, Home, End, Enter, and Space for full keyboard control.
Public API to open, close, and toggle items. Custom events fire on state change for analytics or dependent UI.
All panels expand automatically so no content is hidden on paper.
High contrast and screen reader support built into every state.
Usage Guidelines
Modifier Classes
| Class | Applies to | Description |
|---|---|---|
nds-lg | .nds-accordion | Large size: 56px header height, --spacing-xl padding (default) |
nds-md | .nds-accordion | Medium size: 48px header height, --spacing-lg padding |
nds-sm | .nds-accordion | Small size: 40px header height, --spacing-md padding |
nds-card | .nds-accordion | Card container view: collapses outer border and uses card gap. Combine with nds-stroke and nds-shadow for the full card look |
nds-stroke | .nds-accordion.nds-card | Adds an outer border to the card container |
nds-shadow | .nds-accordion.nds-card | Adds elevation shadow to the card container |
Data Attributes
| Attribute | Applies to | Description |
|---|---|---|
data-state="always-open" | .nds-accordion | Allows multiple panels to be open at the same time. Without it, opening one panel closes the others |
data-state="open" | .nds-accordion-btn and .nds-accordion-collapse | Server-rendered initial open state. Set on both the button and its collapse panel to expand a panel before JS initializes, preventing a 0fr animation on load |
data-nds-accordion-initialized | .nds-accordion | Stamped by JS after initialization. Enables collapse transitions and removes the skeleton loading state. Do not set this manually |
CSS Custom Properties
| Property | Default | Description |
|---|---|---|
--accordion-header-height | 56px | Height of each accordion button. Overridden per size class (nds-lg/md/sm). Set inline on .nds-accordion to customize a single instance |
--accordion-header-padding | --spacing-xl | Inline padding of the accordion button. Overridden per size class. Set inline on .nds-accordion to customize a single instance |
Loading and Skeleton State
The accordion shows a shimmer skeleton on its items in three situations: before JS initializes (:not([data-nds-accordion-initialized])), when explicitly set to loading (nds-loading class or data-state="loading"), and when it is a filter target waiting for the filter to apply URL params (data-filter-items without data-nds-filter-initialized). Titles, leading icons, and open body content all animate as skeleton bars. Collapse transitions are suppressed until the init stamp lands so the initial open state paints without a 0fr transition.
When to Use
- Use accordions to progressively disclose content. Show headings first, let users expand what they need
- Good for FAQs, categorized service lists, and settings panels where users scan then drill down
- Avoid accordions for content users need to compare side-by-side. Use tabs or a flat layout instead
- Keep accordion titles short and scannable. Users decide whether to expand based on the title alone
JavaScript API
The NDS.Accordion API provides methods to create instances, control panels programmatically, and listen for state changes. For dynamically added accordions, call NDS.Accordion.reinit() to initialize new elements.