Version 0.14.3

Accordion

A collapsible panel with title and subtitle for organizing content into expandable sections.

Usage#

import { Accordion, AccordionTrigger, AccordionPanel } from '@backstage/ui';

<Accordion>
  <AccordionTrigger title="Toggle Panel" />
  <AccordionPanel>Your content</AccordionPanel>
</Accordion>

API reference#

Accordion#

Root container for the accordion. Renders a <div> element.

PropTypeDefaultDescription
children
ReactNode(state: { isExpanded: boolean }) => ReactNode
-Content of the accordion. Can be a render function to access expanded state.
defaultExpanded
boolean
falseWhether the accordion is expanded on initial render.
isExpanded
boolean
-Controls the expanded state (controlled mode).
onExpandedChange
(isExpanded: boolean) => void
-Called when the expanded state changes.
className
string
-Additional CSS class name for custom styling.
style
CSSProperties
-Inline CSS styles object.

Inherits all React Aria Disclosure props.

AccordionTrigger#

Trigger component with built-in animated chevron icon. Renders a heading element (defaults to <h3>, configurable via level prop) wrapping a <button>.

PropTypeDefaultDescription
level
123456
3Heading level for accessibility (renders h1-h6). Match your page hierarchy.
title
string
-Primary text displayed in the trigger.
subtitle
string
-Secondary text displayed next to the title.
children
ReactNode
-Custom trigger content. When provided, title and subtitle are ignored.
className
string
-Additional CSS class name for custom styling.
style
CSSProperties
-Inline CSS styles object.

AccordionPanel#

Panel with the accordion content. Renders a <div> element.

PropTypeDefaultDescription
children
ReactNode
-Content displayed when the accordion is expanded.
className
string
-Additional CSS class name for custom styling.
style
CSSProperties
-Inline CSS styles object.

AccordionGroup#

Container for managing multiple accordions. Renders a <div> element.

PropTypeDefaultDescription
allowsMultiple
boolean
falseWhether multiple accordions can be expanded at the same time.
children
ReactNode
-Accordion components to group together.
className
string
-Additional CSS class name for custom styling.
style
CSSProperties
-Inline CSS styles object.

Inherits all React Aria DisclosureGroup props.

Examples#

With Subtitle#

Accordions can display a subtitle below the title.

<Accordion>
  <AccordionTrigger
    title="Advanced Settings"
    subtitle="Configure additional options"
  />
  <AccordionPanel>
    <Text>Your content here</Text>
  </AccordionPanel>
</Accordion>

Custom Trigger#

Pass custom content as children instead of using the title prop.

Default Expanded#

<Accordion defaultExpanded>
  <AccordionTrigger title="Toggle Panel" />
  <AccordionPanel>
    <Text>Your content here</Text>
  </AccordionPanel>
</Accordion>

It's the edge of the world and all of Western civilization

The sun may rise in the East, at least it settled in a final location

It's understood that Hollywood sells Californication

Group Single Open#

Use AccordionGroup to allow only one accordion open at a time.

Group Multiple Open#

Allows multiple panels to be open simultaneously.

Theming#

Our theming system is based on a mix between CSS classes, CSS variables and data attributes. If you want to customise this component, you can use one of these class names below.

  • bui-Accordion

Changelog#

Version 0.13.0#

Breaking Changes

  • Accordion Breaking Simplified the neutral background prop API for container components. The explicit neutral-1, neutral-2, neutral-3, and neutral-auto values have been removed from ProviderBg. They are replaced by a single 'neutral' value that always auto-increments from the parent context, making it impossible to skip or pin to an explicit neutral level. #33002

    Migration Guide:

    Replace any explicit bg="neutral-1", bg="neutral-2", bg="neutral-3", or bg="neutral-auto" props with bg="neutral". To achieve a specific neutral level in stories or tests, use nested containers — each additional bg="neutral" wrapper increments by one level.

    // Before
    <Box bg="neutral-2">...</Box>
    
    // After
    <Box bg="neutral">
      <Box bg="neutral">...</Box>
    </Box>
    

Changes

  • Accordion Made Accordion a bg provider so nested components like Button auto-increment their background level. Updated useDefinition to resolve bg propDef defaults for provider components. #32935

  • Accordion Fixed focus ring styles to use React Aria's [data-focus-visible] data attribute instead of the native CSS :focus-visible pseudo-class. This ensures keyboard focus rings render reliably when focus is managed programmatically by React Aria (e.g. inside a GridList, Menu, or Select). #33358

Version 0.12.0#

Changes

  • Accordion Fixed nested Accordion icon state issue where the inner accordion's arrow icon would incorrectly show as expanded when only the outer accordion was expanded. The CSS selector now uses a direct parent selector to ensure the icon only responds to its own accordion's expanded state. #32488