Collapse
Collapse
Collapse is a component which toggles content. Useful for grouping great amount of texts and/or graphics into expanding and collapsing items.
Collapse is used to show and hide content. Buttons or anchors are used as triggers that are mapped to specific elements you toggle. Collapsing an element will animate the height from its current value to 0.
Example
Default Collapse example.

import React from "react";import { CDBBtn, CDBCollapse, CDBContainer } from "cdbreact";class Collapse extends Component {state = {collapseID: "",};toggleCollapse = (collapseID) => () => {this.setState((prevState) => ({collapseID: prevState.collapseID !== collapseID ? collapseID : "",}));};render() {return (<CDBContainer><divstyle={{margin: "auto",width: "80%",display: "flex",flexDirection: "column",alignItems: "center",justifyContent: "center",minHeight: "100vh",}}><CDBBtncolor="primary"onClick={this.toggleCollapse("basicCollapse")}style={{ marginBottom: "1rem" }}>COLLAPSE BUTTON</CDBBtn><CDBCollapse id="basicCollapse" isOpen={this.state.collapseID}><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed doeiusmod tempor incididunt ut labore et dolore magna aliqua. Utenim ad minim veniam, quis nostrud exercitation ullamco laborisnisi ut aliquip ex ea commodo consequat. Duis aute irure dolor inreprehenderit in voluptate velit esse cillum dolore eu fugiatnulla pariatur. Excepteur sint occaecat cupidatat non proident,sunt in culpa qui officia deserunt mollit anim id est laborum</p></CDBCollapse></div></CDBContainer>);}}
API
In this section you will find advanced information about the Collapse component. You will find out which modules are required, what are the possibilities of configuring the component, and what events and methods you can use to work with it.
Contrast Collapse Import Statement
You need to import the Contrast Collapse component first before using it.
import { CDBCollapse } from "cdbreact";
API Reference: Contrast Collapse Properties
The table below shows the configuration options of the CDBCollapse component.
| Name | Type | Default | Description | Example |
|---|---|---|---|---|
| className | String | Adds custom classes | <CDBCollapse className="myClass" ... /> | |
| delay | Number or Object | {show: 350, hide: 350} | Defines how many milliseconds the open/close event are delayed | <CDBCollapse delay={{show: 3000, hide: 7000}} ... /> |
| disable | Boolean | false | Disables Collapse component | <CDBCollapse disabled .../> |
| navbar | Boolean | false | Adds navbar-collapse bootstrap class to class name property | <CDBCollapse navbar ... /> |
| isOpen | String or Boolean | Defines if accordion is opened or closed | <CDBCollapse isOpen ... /> | |
| onOpened | function | Defines the function which fires when Accordion has opened | <CDBCollapse onOpened={yourFunction} ... /> | |
| onClosed | function | Defines the function which fires when Accordion has closed | <CDBCollapse onClosed={yourFunction} ... /> |