Aller au contenu principal

Collapse Component

Description

The Collapse component allows content to expand and collapse smoothly with an animation.

Props

PropTypeDefaultDescription
inbooleanfalseControls whether the content is expanded or collapsed.
timeoutnumber0Duration of the expand/collapse transition (in milliseconds).
collapsedHeightstring"0px"The height of the content when collapsed.

Example Usage

import { Collapse, Button } from "@nomana-it/liberty-core"
import { useState } from "react";

export const CollapseExample = () => {
const [open, setOpen] = useState(false);

return (
<div>
<Button onClick={() => setOpen((prev) => !prev)}>
{open ? "Collapse" : "Expand"}
</Button>
<Collapse in={open} timeout={300} collapsedHeight="0px">
<div style={{ padding: "10px", backgroundColor: "#f5f5f5", borderRadius: "8px" }}>
This content is collapsible.
</div>
</Collapse>
</div>
);
};

🔗 GitHub Repository (Core): Liberty Core
🔗 GitHub Repository (Test Project): Liberty Test
📖 Live Documentation: Liberty Core Docs
💖 Sponsor & Support: Sponsor Liberty Core