Accordion
Accordions are collapsible content containers that let users reveal or hide sections of content. They reduce cognitive load by surfacing only the most relevant content on first glance and letting users choose how deep to dig.
Ready to use
This component is fully responsive and intentionally designed to be used across all viewports — mobile, tablet, and desktop — with no alternative versions required.
Anatomy
Section titled “Anatomy”Accordion title
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore.
- Accordion
- Trigger
- Title
- Chevron
- Content
When to use it
Section titled “When to use it”Use the accordion when:
- You need to present several groups of related information, but not all of it needs to be visible at once.
- You want to reduce visual clutter and keep the page easier to scan.
- Users may only need to access some details depending on their specific needs or interests.
- You want to avoid long scrolling, especially on mobile devices or content-dense pages.
- The content in each section can be understood independently from the rest.
Avoid the accordion when:
- The content is essential for understanding the page and should remain visible without interaction.
- Users need to compare information across multiple sections at the same time.
- The page only contains one section of information (in that case, display it directly).
- Frequent opening and closing would interrupt the user’s workflow or slow them down.
Properties
Section titled “Properties”Accordion
The whole disclosure component — a <details> element that owns the open/closed state and wraps the trigger and content.
Trigger
The row that toggles the accordion. Always keyboard-focusable; the title text doubles as the accessible name.
Title
The label inside the trigger that names the disclosure and carries its accessible name.
Chevron
A chevron that rotates between collapsed and expanded states. Decorative — the open/closed state is also conveyed via aria-expanded.
Content
The collapsible content region. Hidden from assistive tech when collapsed and revealed in document order when expanded.
Platform considerations
Section titled “Platform considerations”Desktop
On desktop the full accordion stack is visible at once. Keep the trigger row tall enough for comfortable pointer targets and let the panel content flow naturally without artificial caps.
Tablet
The same stack adapts to narrower widths. Respect the 44×44 px touch target on the header so the component remains comfortable to tap.
Mobile
On mobile, prefer single-item expansion to reduce scroll jumps. Keep titles short so they fit on a single line at the smallest breakpoint.
Best practices
Section titled “Best practices”Use the accordion to progressively disclose detail — never to bury content users actually need.
Do
Group related items, write concise scannable titles, and keep consistent spacing between accordions to support visual rhythm.
Don't
Avoid nesting accordions, hiding essential information, or stacking more items than a user can reasonably scan in one view.
Content guidelines
Section titled “Content guidelines”Keep titles short and scannable — typically one line. Lead with the keyword that helps users identify the content at a glance, and use sentence case for readability (for example “Account details”, not “ACCOUNT DETAILS”). When several accordions sit together, write titles in parallel structure (all nouns or all verbs) so the group reads as a coherent set. Avoid hiding content that users need on every visit; if it’s critical, show it directly instead.
Styles
Section titled “Styles”The accordion can leverage <details> and <summary> elements, providing built-in expand/collapse behavior without JavaScript.
<details class="tng-accordion"> <summary class="tng-accordion-trigger"> <span>Accordion title</span> <i class="tng-icon icon-chevron-down" aria-hidden="true"></i> </summary> <p class="tng-text-body"> Lorem ipsum dolor sit amet, consectetur adipiscing elit. </p></details>Accordion title
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Accordion title
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Elements
Section titled “Elements”Add an icon before the title for visual context.
<details class="tng-accordion"> <summary class="tng-accordion-trigger"> <i class="tng-icon icon-profile" aria-hidden="true"></i> <span>Account details</span> <i class="tng-icon icon-chevron-down" aria-hidden="true"></i> </summary> <p class="tng-text-body"> Manage your account settings and preferences. </p></details>Account details
Manage your account settings and preferences.
Account details
Manage your account settings and preferences.
Modules
Section titled “Modules”Accordion group
Section titled “Accordion group”Multiple accordions can be stacked using our flex layout, optionally adding a divider.
<div class="tng-stack gap-none align-items-stretch | tng-has-dividers"> <details class="tng-accordion" open> <summary class="tng-accordion-trigger"> <i class="tng-icon icon-profile" aria-hidden="true"></i> <span>Personal information</span> <i class="tng-icon icon-chevron-down" aria-hidden="true"></i> </summary> <div class="tng-slot is-primary"></div> <p class="tng-text-body"> Your personal information is kept private and secure. </p> </details> <button class="tng-button is-lg is-tertiary is-ghost pb-xl | justify-content-space-between" > Inline Button <i class="tng-icon icon-external-link" aria-hidden="true"></i> </button> <details class="tng-accordion"> <summary class="tng-accordion-trigger"> <i class="tng-icon icon-settings" aria-hidden="true"></i> <span>Settings</span> <i class="tng-icon icon-chevron-down" aria-hidden="true"></i> </summary> <p class="tng-text-body"> Configure your preferences and settings. </p> </details> <details class="tng-accordion"> <summary class="tng-accordion-trigger"> <i class="tng-icon icon-info" aria-hidden="true"></i> <span>Help & Support</span> <i class="tng-icon icon-chevron-down" aria-hidden="true"></i> </summary> <p class="tng-text-body"> Get help with common issues and contact support. </p> </details></div>Personal information
Your personal information is kept private and secure.
Settings
Configure your preferences and settings.
Help & Support
Get help with common issues and contact support.
Personal information
Your personal information is kept private and secure.
Settings
Configure your preferences and settings.
Help & Support
Get help with common issues and contact support.
Import the Accordion and AccordionItem components from @tmedxp/react-components.
Properties
Section titled “Properties”AccordionProperties extends PropsWithChildren<ComponentProps<'div'>>, meaning it includes all standard HTML attributes that can be applied to a <div>.
| Prop | Type | Description | Optional |
|---|---|---|---|
className |
string |
Custom classNames you want to apply to the accordion. | ✅ |
children |
React.ReactElement<typeof AccordionItem> | React.ReactElement<typeof AccordionItem>[] |
Set of accordion items. | ❌ |
hasDivider |
boolean |
Display or not a divider. Displayed by default. | ✅ |
AccordionItem properties
Section titled “AccordionItem properties”AccordionItemProperties extends PropsWithChildren<ComponentProps<'details'>>, meaning it includes all standard HTML attributes that can be applied to a <details>.
| Prop | Type | Description | Optional |
|---|---|---|---|
className |
string |
Custom classNames you want to apply to the accordion. | ✅ |
title |
string |
The accordion title. | ❌ |
iconName |
IconProperties['name'] |
The accordion icon name. | ✅ |
children |
React.ReactElement |
The accordion content. | ❌ |
open |
boolean |
HTML property. Defines the initial accordion state. | ✅ |
Example
Section titled “Example”import { Accordion, AccordionItem } from '@tmedxp/react-components';
const ExampleAccordion = (items) => { return ( <Accordion id="accordion-simple"> {items.map((item, key) => ( <AccordionItem key={key} title={item.title} name={item.name} open={item.open} hasDivider={item.hasDivider} iconName={item.iconName} > <div dangerouslySetInnerHTML={{ __html: item.HTMLContent }} /> </AccordionItem> ))} </Accordion> );};
export { ExampleAccordion };The accordion follows the WAI-ARIA APG Accordion pattern — a stack of headers that each show or hide a section of content — and meets WCAG 2.1 AA. An accessible accordion keeps every header reachable and toggleable from the keyboard, keeps assistive technology informed of each section’s expanded or collapsed state, and gives every header and panel an accessible name — so its structure is clear whether the user is looking at it, listening to it, or tabbing through it.
For designers
Section titled “For designers”- All accordion states (collapsed, expanded, hover, and focus) must maintain accessible contrast on every supported surface. Source: WCAG 1.4.3 Contrast (Minimum).
- The open/closed state must never be conveyed by colour alone — pair it with a shape change such as the chevron rotation, a border, or a background shift. Source: WCAG 1.4.1 Use of Color.
- Focus styles must stay visible, meet contrast requirements on every supported surface, and be clearly distinguishable from hover. Source: WCAG 2.4.7 Focus Visible.
- Use semantic colour tokens (e.g.
foreground/neutral/default) rather than fixed values, so the accordion adapts correctly across themes and surfaces.
For developers
Section titled “For developers”Build each header from native <details> and <summary>: the <summary> is the accordion’s header control and the parent <details> owns the open/closed state, so no extra ARIA is required. Use the name attribute on the <details> elements to make an exclusive group where only one section is open at a time. Each header is its own tab stop — accordions use sequential tab stops, not a roving tabindex (unlike Tabs), so Tab visits every header in turn; when an open panel holds focusable content, that content follows its header in the tab sequence before Tab reaches the next header. If you must build a custom accordion without <details>, put a <button> inside a heading of the appropriate level and wire it to its panel yourself — APG’s Accordion pattern then adds optional arrow-key and Home/End navigation between headers. The per-element roles, names, and states are in the Labelling elements section below. Mark the decorative chevron aria-hidden="true" so screen readers skip it.
Keyboard interaction
Section titled “Keyboard interaction”| Key | Action |
|---|---|
| Enter / Space | Toggle the focused accordion open or closed |
| Tab / Shift + Tab | Move to the next / previous accordion header |
Interactive targets must be at least 44 px high for comfortable touch use — comfortably clearing the WCAG AA minimum. Source: WCAG 2.5.8 Target Size (Minimum).
Labelling elements
Section titled “Labelling elements”Give every element the role, name, and state assistive technology needs.
Header trigger
The <summary> is the accordion’s header control; the browser gives it the toggle role and keeps its expanded/collapsed state in sync with the parent <details>. In a custom build, use a <button> with aria-expanded inside a heading and point aria-controls at its panel’s id. Its accessible name comes from the visible title text — never ship an icon-only header.
Content region
The panel is revealed in document order when its header expands and hidden when it collapses. In a custom build, give it role="region" with aria-labelledby referencing the header, so screen-reader users can find and identify each open section. Keep the header text self-describing so the region’s name stays meaningful.
Source: WCAG 4.1.2 Name, Role, Value.