Skip to content

ExpandableSection - support dynamic toggleContent #12030

@dgdavid

Description

@dgdavid

Is this a new component or an extension of an existing one?

Extension of ExpandableSection#toggleContent.

Describe the feature

It’s great that ExpandableSection supports a detached mode for advanced customization, but in many cases, using the detached setup feels like overkill, especially when the only requirement is to slightly adjust the toggleContent based on the expanded state.

Introducing support for a functional form of toggleContent (e.g., a function that receives isExpanded) would provide a simpler, more flexible API for customizing toggle content without having to fully detach the section logic.

<ExpandableSection
  toggleContent={(isExpanded) =>
    isExpanded ? <ExpandedToggleContent /> : <CollapsedToggleContent />
  }
/>

Are there visuals for this feature? If applicable, please include examples for each state and for varying widths

No

Any other information?

Alternatively, to align with the existing toggleText API, the component could support separate props like toggleContentExpanded and toggleContentCollapsed.

Either approach would make ExpandableSection more flexible and ergonomic for common UI scenarios.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

Status

Ready to assign

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions