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

NameTypeDescriptionDefault
Required
label
stringThe panel label.-
defaultIsExpandedbooleanInitial state of the panel, only when it is uncontrolled.-
isExpandedbooleanRepresents 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.-
iconstring | (React.ReactNode & React.SVGProps <SVGSVGElement>)Material Symbol name or SVG element as the icon that will be placed next to the panel label. When using Material Symbols, replace spaces with underscores. By default they are outlined if you want it to be filled prefix the symbol name with "filled_".-
assistiveTextstringAssistive text to be placed on the right side of the panel.-
disabledbooleanIf true, the component will be disabled.false
onChange(isExpanded: boolean) => voidThis 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.-
Required
children
React.ReactNodeThe expanded panel of the accordion. This area can be used to render custom content.-
margin'xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge' | MarginSize of the margin to be applied to the component. You can pass an object with 'top', 'bottom', 'left' and 'right' properties in order to specify different margin sizes.-
tabIndexnumberValue of the tabindex attribute.0

Accordion Group

Groups two or more accordions to distribute large volumes of information.

Props

NameTypeDescriptionDefault
defaultIndexActivenumberInitially active accordion, only when it is uncontrolled.-
indexActivenumberThe 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.-
disabledbooleanIf true, the component will be disabled.false
onActiveChange(indexActive: number) => voidThis function will be called when the user clicks on an accordion. The index of the clicked accordion will be passed as a parameter.-
Required
children
React.ReactElement <AccordionPropsType>[] | React.ReactElement <AccordionPropsType>Contains one or more accordions.-
margin'xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge' | MarginSize of the margin to be applied to the component. You can pass an object with 'top', 'bottom', 'left' and 'right' properties in order to specify different margin sizes.-

DxcAccordionGroup.Accordion

Single accordion, part of an accordion group.

Props

NameTypeDescriptionDefault
Required
label
stringThe panel label.-
iconstring | React.ReactNode & React.SVGProps <SVGSVGElement>Material Symbol name or SVG element as the icon that will be placed next to the panel label. When using Material Symbols, replace spaces with underscores. By default they are outlined if you want it to be filled prefix the symbol name with "filled_".-
assistiveTextstringAssistive text to be placed on the right side of the panel.-
disabledbooleanIf true, the component will be disabled.false
Required
children
React.ReactNodeThe expanded panel of the accordion. This area can be used to render custom content.-

Examples

Controlled Accordion

Uncontrolled Accordion

Controlled Accordion Group

Uncontrolled Accordion Group

Icons