Accordion

Accordions are used to group similar content and hide or show it depending on user needs or preferences. Accordions give users more granular control over the interface and help digest content in stages, rather than all at once.

Props

warning
The padding prop has been deprecated. Consider using layout components like the Inset for the same purpose.

Accordion

NameDefaultDescription
label: stringThe panel label.
icon: node | stringElement or path used as the icon that will be placed next to panel label.
assistiveText: stringAssistive text to be placed on the right side of the panel.
disabled: booleanfalseIf true, the component will be disabled.
defaultIsExpanded: booleanInitial state of the panel, only when it is uncontrolled.
isExpanded: booleanRepresents the state of the panel. When true, the component will be expanded. If undefined, the component will be uncontrolled and its value will be managed internally by the component.
onChange: functionThis function will be called when the user clicks the accordion to expand or collapse the panel. The new state of the panel will be passed as a parameter.
children: nodeThe expanded panel of the accordion. This area can be used to render custom content.
margin: string | objectSize of the margin to be applied to the component ('xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge'). You can pass an object with 'top', 'bottom', 'left' and 'right' properties in order to specify different margin sizes.
padding: string | object
Deprecated
Size of the padding to be applied to the custom area ('xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge'). You can pass an object with 'top', 'bottom', 'left' and 'right' properties in order to specify different padding sizes.
tabIndex: number0Value of the tabindex.

Accordion Group

NameDefaultDescription
defaultIndexActive: numberInitially active accordion, only when it is uncontrolled.
indexActive: numberThe index of the active accordion. If undefined, the component will be uncontrolled and the active accordion will be managed internally by the component. If null, the component will be controlled and all accordions will be closed.
disabled: booleanfalseIf true, the component will be disabled.
onActiveChange: functionThis function will be called when the user clicks on an accordion. The index of the clicked accordion will be passed as a parameter.
margin: string | objectSize of the margin to be applied to the component ('xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge'). You can pass an object with 'top', 'bottom', 'left' and 'right' properties in order to specify different margin sizes.

DxcAccordionGroup.Accordion

This must be defined as children of the accordion group. It has the following props:

Props
NameDefaultDescription
label: stringThe panel label.
icon: node | stringElement or path used as the icon that will be placed next to panel label.
assistiveText: stringAssistive text to be placed on the right side of the panel.
disabled: booleanfalseIf true, the component will be disabled.
children: nodeThe expanded panel of the accordion. This area can be used to render custom content.
padding: string | object
Deprecated
Size of the padding to be applied to the custom area ('xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge'). You can pass an object with 'top', 'bottom', 'left' and 'right' properties in order to specify different padding sizes.

Examples

Controlled Accordion

Uncontrolled Accordion

Controlled Accordion Group

Uncontrolled Accordion Group

Icons