The Collapse component is used to hide and show an element.
| Params |
Description |
Type |
| collapseElement |
The element to be collapsed/expanded |
HTMLElement |
| triggerElement |
The element that triggers the collapse |
HTMLElement | null |
| options |
Additional options for the Collapse |
CollapseOptions |
| Option |
Description |
Type |
| orientation |
The orientation of the collapse |
"vertical" | "horizontal" | "vertical" |
| defaultState |
The default state of the collapse |
"open" | "close" | "close" |
const options = {
orientation: "vertical",
defaultState: "close",
};
const collapse = new Collapse(
'#myCollapseElement',
options,
'#myTriggerElement',
);
collapse.show();
collapse.hide();
collapse.toggle();