Collapsible
Leave feedbackCollapsible is an element that allows a user to toggle (view/hide) supplemental information or actions.
When to use:
- To organize related information.
- To shorten pages and reduce scrolling when content is not crucial to read in full.
- When space is at a premium and long content cannot be displayed all at once.
Basic Usage
The styling prop at the top level <Collapsible /> component determines if the collapsible has basic styling, card, or card with heading.
Basic Style
Any Paragon component or export may be added to the code example.
Card Style
This is the default style if no styling prop is supplied.
Any Paragon component or export may be added to the code example.
Default Open
Any Paragon component or export may be added to the code example.
With Callbacks
Any Paragon component or export may be added to the code example.
Advanced Usage
For needs that deviate from the three styles above, use <Collapsible.Advanced />
Bare minimum
Any Paragon component or export may be added to the code example.
Card style with advanced usage
Any Paragon component or export may be added to the code example.
With a close button
Any Paragon component or export may be added to the code example.
onOpen, onClose and onToggle callbacks
See the developer console for logging.
Any Paragon component or export may be added to the code example.
Controlled usage
Any Paragon component or export may be added to the code example.
Imperative methods
If you need to open or close the Collapsible intermittently due to an event,
such as loading the page or clicking a link, you can open or close
an uncontrolled Collapsible by getting a ref to the component and calling
collapsibleRef.open() or collapsibleRef.close(). The internal state of
the component will be updated accordingly.
Theme Variables (SCSS)#
$collapsible-card-spacer-y: .5rem !default;$collapsible-card-spacer-x: .5rem !default;$collapsible-card-spacer-y-lg: $card-spacer-y !default;$collapsible-card-spacer-x-lg: $card-spacer-x !default;$collapsible-card-body-spacer-left: .75rem !default;$collapsible-card-spacer-icon: 2.5rem !default;$collapsible-basic-spacer-y: .5rem !default;$collapsible-basic-spacer-x: .5rem !default;$collapsible-basic-spacer-icon: .625rem !default;
Props API#
- children
nodeRequiredSpecifies contents of the component.
- className
stringSpecifies class name to append to the base element.
- defaultOpen
boolDefaultfalseSpecifies whether the
Collapsibleshould be initially open. - iconWhenClosed
elementDefault<Icon src={ExpandMore} />Specifies icon to show when
Collapsibleis closed. - iconWhenOpen
elementDefault<Icon src={ExpandLess} />Specifies icon to show when
Collapsibleis open. - onClose
funcCallback fired when
Collapsiblecloses. - onOpen
funcCallback fired when
Collapsibleopens. - onToggle
funcCallback fired when
Collapsible'sstate is toggled. - open
boolSpecifies whether
Collapsibleis open. - styling
enum'basic' | 'card' | 'card-lg'Default'card'Specifies style variant.
- title
nodeRequiredSpecifies title.
- unmountOnExit
boolDefaulttrueUnmount the component (remove it from the DOM) when it is collapsed
- children
nodeSpecifies contents of the component.
- className
stringSpecifies classname to append to the base element.
- defaultOpen
boolDefaultfalseSpecifies whether
Collapsibleshould be initially open. - open
boolSpecifies whether
Collapsibleis open. - onToggle
funcCallback fired when
Collapsible'sstate is toggled. - onOpen
funcCallback fired when
Collapsibleopens. - onClose
funcCallback fired when
Collapsiblecloses. - unmountOnExit
boolDefaulttrueUnmount the component (remove it from the DOM) when it is collapsed.
- children
nodeSpecifies contents of the component.
- tag
stringDefault'div'Specifies content's base element.
- transitionWrapper
elementSpecifies transition element.
- children
nodeSpecifies contents of the component.
- tag
string|elementTypeDefault'div'Specifies base element.
- openOnly
boolDefaultfalseSpecifies whether toggling
Collapsible'sstate will always trigger only open action. - closeOnly
boolDefaultfalseSpecifies whether toggling
Collapsible'sstate will always trigger only close action. - onClick
funcCallback fired when element gets clicked.
- onKeyDown
funcCallback fired when a key is pressed.
- children
nodeSpecifies contents of the component.
- whenOpen
boolDefaultfalseSpecifies whether the content should be visible when
Collapsibleis open. - whenClosed
boolDefaultfalseSpecifies whether the content should be visible when
Collapsibleis closed.
Usage Insights#
Collapsible
| Project Name | Paragon Version | Instance Count | |
|---|---|---|---|
| frontend-app-account | 20.44.0 | 4 | |
| frontend-app-admin-portal | 20.39.2 | 3 | |
| frontend-app-communications | 20.45.0 | 2 | |
| frontend-app-course-authoring | 20.35.1 | 1 | |
| frontend-app-gradebook | 20.45.0 | 4 | |
| frontend-app-learner-portal-enterprise | 20.45.1 | 4 | |
| frontend-app-learner-portal-programs | 20.30.0 | 1 | |
| frontend-app-learning | 20.28.4 | 1 | |
| frontend-app-ora-grading | 20.45.1 | 1 | |
| frontend-app-payment | 20.45.0 | 1 | |
| frontend-app-program-console | 20.32.0 | 2 | |
| frontend-app-publisher | 20.28.5 | 1 | |
| frontend-learner-portal-base | 12.2.0 | 1 | |
| prospectus | 20.45.2 | 12 |
CollapsibleAdvanced
| Project Name | Paragon Version | Instance Count | |
|---|---|---|---|
| frontend-app-account | 20.44.0 | 1 | |
| frontend-app-course-authoring | 20.35.1 | 1 | |
| frontend-app-discussions | 20.44.0 | 3 | |
| frontend-app-learner-portal-enterprise | 20.45.1 | 2 | |
| frontend-app-learning | 20.28.4 | 3 | |
| frontend-app-ora-grading | 20.45.1 | 1 | |
| frontend-app-publisher | 20.28.5 | 1 | |
| frontend-lib-content-components | 20.45.0 | 8 | |
| prospectus | 20.45.2 | 3 |
CollapsibleBody
| Project Name | Paragon Version | Instance Count | |
|---|---|---|---|
| frontend-app-account | 20.44.0 | 1 | |
| frontend-app-course-authoring | 20.35.1 | 1 | |
| frontend-app-discussions | 20.44.0 | 3 | |
| frontend-app-learner-portal-enterprise | 20.45.1 | 2 | |
| frontend-app-learning | 20.28.4 | 3 | |
| frontend-app-ora-grading | 20.45.1 | 1 | |
| frontend-lib-content-components | 20.45.0 | 7 | |
| prospectus | 20.45.2 | 3 |
CollapsibleTrigger
| Project Name | Paragon Version | Instance Count | |
|---|---|---|---|
| frontend-app-account | 20.44.0 | 1 | |
| frontend-app-course-authoring | 20.35.1 | 1 | |
| frontend-app-discussions | 20.44.0 | 3 | |
| frontend-app-learner-portal-enterprise | 20.45.1 | 2 | |
| frontend-app-learning | 20.28.4 | 3 | |
| frontend-app-ora-grading | 20.45.1 | 1 | |
| frontend-app-publisher | 20.28.5 | 1 | |
| frontend-lib-content-components | 20.45.0 | 3 | |
| prospectus | 20.45.2 | 1 |
CollapsibleVisible
| Project Name | Paragon Version | Instance Count | |
|---|---|---|---|
| frontend-app-course-authoring | 20.35.1 | 4 | |
| frontend-app-discussions | 20.44.0 | 6 | |
| frontend-app-learner-portal-enterprise | 20.45.1 | 4 | |
| frontend-app-learning | 20.28.4 | 6 | |
| frontend-app-ora-grading | 20.45.1 | 2 | |
| frontend-app-publisher | 20.28.5 | 2 | |
| frontend-lib-content-components | 20.45.0 | 4 | |
| prospectus | 20.45.2 | 6 |