Accordion
Accordion is a lightweight, animated disclosure panel. It shows a title with a chevron and reveals its children when expanded, using a smooth height transition. It works in every SpartanFX target (SPFx, PCF, Code Apps, standalone React) with no host context.
When to use
- Progressive disclosure — hide secondary detail behind a title the user can expand.
- FAQ-style lists, "advanced settings" sections, or long forms broken into collapsible groups.
- A titled, non-collapsible section (use
staticMode) when you want the accordion's framing without the toggle.
Reach for something else when you need tabs (mutually exclusive panels) or a full side panel — those aren't disclosure patterns.
Import
import { Accordion } from '@spartanfx/react';
Basic usage
The only required prop is title. The accordion starts collapsed.
<Accordion title="Shipping details">
Ships in 2–3 business days. Free returns within 30 days.
</Accordion>
Start expanded
Pass defaultOpen to render it open on first paint.
<Accordion title="What is SpartanFX?" defaultOpen>
A React + TypeScript component library that runs across SPFx, PCF,
Power Apps Code Apps, and standalone React.
</Accordion>
Static section
staticMode keeps the accordion's styling but removes the expand/collapse toggle — a titled frame that's always open. (It ignores defaultOpen.)
<Accordion title="Summary" staticMode>
This content is always visible, wrapped in the accordion's frame.
</Accordion>
Theming
Accordion honors dark mode through the appearance prop and can be themed with design tokens or class overrides:
import { AppearanceMode } from '@spartanfx/react';
<Accordion title="Dark panel" appearance={AppearanceMode.dark}>
Themed for a dark surface.
</Accordion>
tokens— design tokens (CSS custom properties) viaIAccordionTokens.classes— per-element class overrides viaIAccordionClassNames.className/style— root element overrides.
Props
| Prop | Type | Default | Notes |
|---|---|---|---|
title (required) | string | — | Text shown next to the chevron. |
defaultOpen | boolean | false | Start expanded. |
staticMode | boolean | false | Non-collapsible titled section. |
appearance | AppearanceMode | light | Light or dark theming. |
ariaLabel | string | — | Accessible label. |
See the full generated reference: Accordion API ↗.