ExpandCollapse

core package3.2.2

Note: All components shown on this site are supported by the Constellation design system. To learn how to configure Theme Cosmos, visit Pega Community.

The ExpandCollapse component can be wrapped around any content that should be hidden or shown depending on state. When the component is collapsed, its children will be hidden and the surrounding content will pull in to fill the empty space. If you would like to expand and collapse content without pushing and pulling the surrounding elements, try using the Drawer component.

Usage

The ExpandCollapse component can be opened along either dimension (height or width) by setting the dimension prop. In addition, min and max props are provided to control the limits on how far the component may expand or collapse.

You can control how quickly the component expands and collapses by by passing a CSS time value to transitionSpeed, which is a string containing any positive number directly followed by 's' or 'ms'. If you would like no transition, pass 0 the to transitionSpeed prop. Callback functions are provided to allow for event handling before and after the component expands and collapses.

Related components

Properties

NameDescriptionDefaultType
asHTML tag or React Component to render the component as.ElementType<any>
childrenContent to expand/collapse.ReactNode
classNameAdditional CSS classes.string
collapsedIf true,the content will be hidden.falseboolean
dimensionUsed to determine the transition property."height"
'height' |'width' 
forwardedAsHTML tag or React Component to finally render the component as.ElementType<any>
maxMaximum height/width to expand to. Expanded state will expanded up until, but not beyond, the natural height/width of the element.string
minMinimum height/width to collapse to. This will set the starting collapsed size as well.string
nullWhenCollapsedIf true, removes the component from the real DOM when collapsed. For full virtual DOM unmount(if necessary), perform at a parent level.falseboolean
onAfterCollapse() => void
onAfterExpand() => void
onBeforeCollapse() => void
onBeforeExpand() => void
transitionSpeedDetermine the speed of animation. This value comes from "0.25s"string