Closed
The default. Header text and a plus icon.
A list of headers that each open and close a panel of related content, so people can scan a long page and open only what they need.
Updated
Accordion
HTML
<div class="nds-accordion nds-accordion--open"> <h3 class="nds-accordion__heading"> <button type="button" class="nds-accordion__trigger" id="accordion-how-do-i-register-a-business-trigger" aria-expanded="true" aria-controls="accordion-how-do-i-register-a-business-panel" > <span class="nds-accordion__title"> How do I register a business? </span> <span class="nds-accordion__icon-wrap" aria-hidden="true"> <svg class="nds-accordion__icon" width="20" height="20" focusable="false" aria-hidden="true"> <use href="#nds-icon-minus-small"> </use> </svg> </span> </button> </h3> <div id="accordion-how-do-i-register-a-business-panel" class="nds-accordion__panel"> <div class="nds-accordion__content"> Register with the Corporate Affairs Commission online. It takes about 3 days. </div> </div></div> WordPress
<!-- wp:nds/accordion {} --><div class="nds-accordion nds-accordion--open"> <h3 class="nds-accordion__heading"> <button type="button" class="nds-accordion__trigger" id="accordion-how-do-i-register-a-business-trigger" aria-expanded="true" aria-controls="accordion-how-do-i-register-a-business-panel" > <span class="nds-accordion__title"> How do I register a business? </span> <span class="nds-accordion__icon-wrap" aria-hidden="true"> <svg class="nds-accordion__icon" width="20" height="20" focusable="false" aria-hidden="true"> <use href="#nds-icon-minus-small"> </use> </svg> </span> </button> </h3> <div id="accordion-how-do-i-register-a-business-panel" class="nds-accordion__panel"> <div class="nds-accordion__content"> Register with the Corporate Affairs Commission online. It takes about 3 days. </div> </div></div><!-- /wp:nds/accordion --> Usage
import { Accordion } from "@nigerian-design-standards/react";<Accordion title="How do I register a business?" content="Register with the Corporate Affairs Commission online. It takes about 3 days." open onToggle={(nextOpen) => { // Toggle hidden on the panel and aria-expanded on the header button }}/> Usage
use NDS\Components\Accordion;echo Accordion::render([ 'title' => 'How do I register a business?', 'content' => 'Register with the Corporate Affairs Commission online. It takes about 3 days.', 'open' => true,]); Use an accordion when content falls into short, parallel sections and most people only need one or two of them. Headers stay visible; each opens its own panel, and several can be open at once.
One header in four states. Hover and focused keep the closed layout; open shows the content.
The default. Header text and a plus icon.
surface/muted behind the header.
Keyboard focus: a 3px border/focus ring with a 1px gap.
A minus icon and the content panel on surface/subtle.
The properties of the accordion. The same in HTML, WordPress and React.
| Property | Type | Possible values | Description |
|---|---|---|---|
| title | string | any text | Required. Says what is inside, as a question or a short phrase. |
| open | boolean |
| Whether the panel starts open. |
| content | string | any text | Required. Keep it short and link out for long content. |
| headingLevel | number | 2 to 6 | Defaults to 3. Follow the page outline. |
In code, the header is a <button type="button"> with aria-expanded and aria-controls, inside a heading that fits the page
outline. The panel uses hidden when closed. People can open more than one panel;
don’t close the others automatically.
| Part | Token | Contrast on the page |
|---|---|---|
| Container | surface/canvas · border/subtle · 1px · radius/050 · spacing/150 · 12px | Border is decorative |
| Expand icon (20px) | icon/Plus Small · icon/Minus Small · text/secondary | 6.6:1 |
| Header text | Label/medium · text/primary | 17.6:1 |
| Hover | surface/muted behind the header | 16.4:1 (text) |
| Focus ring | border/focus, 3px, with a 1px surface/canvas gap | 4.5:1 |
| Open panel | surface/subtle · Body/small · text/secondary · spacing/100 · 8px under the header | 6.4:1 |
Use an accordion for many short, parallel sections people scan, like an FAQ.
Don’t hide what everyone must read, like terms or deadlines. Show it on the page.
How accordions sit on a page.
How to write headers and panels.
“Fees for registration”, not “Information about the fees”.
A few sentences or a list. Link out for the rest.
Don’t write “Click to expand”. The icon and state say it.
| Write | Don’t write | Why |
|---|---|---|
| How do I register a business? | Business registration information | A question people ask. |
| Fees and payment | Click here to see fees | Says what is inside. |
| Documents you need | More information | Specific. |
| Who can apply | WHO CAN APPLY | Sentence case. |
| Opening hours | Hours of operation (expand) | No instructions in the header. |
The header is a button that says whether its panel is open. Colour and icon are never the only signal.
| Key | What it does |
|---|---|
| Tab | Moves to the next header. Links in open panels are reached in reading order. |
| Shift+Tab | Moves back. |
| Enter or Space | Opens or closes the panel. |
Copy the code for HTML, WordPress or React from the Code tab in Live example. The options are listed under Specifications.
Use Accordion from 01 Library – Foundations, or Grouped accordion for a set. Pick the state and edit the Title and Content. Don’t detach it.
Is this page useful?