Layout & Disclosure
@hacline/ui/collapsibleCollapsible
Expand or collapse a single content panel with a trigger button.
Usage
Place CollapsibleTrigger and CollapsiblePanel inside the same root component. Use open and onOpenChange when you need controlled state.
"use client";
import {
Collapsible,
CollapsiblePanel,
CollapsibleTrigger,
} from "@/components/ui/hacline/components/collapsible";
export const Example = () => (
<Collapsible className="max-w-sm">
<CollapsibleTrigger>View backup details</CollapsibleTrigger>
<CollapsiblePanel>
<p>
Backups include project settings, collaborators, and saved versions.
</p>
</CollapsiblePanel>
</Collapsible>
);Controlling the Panel Externally
Manage the open state with open and onOpenChange so both the panel trigger and external buttons can update it.
build completed in 2.1s
"use client";
import { useState } from "react";
import { Button } from "@/components/ui/hacline/components/button";
import {
Collapsible,
CollapsiblePanel,
CollapsibleTrigger,
} from "@/components/ui/hacline/components/collapsible";
export const Example = () => {
const [open, setOpen] = useState(true);
return (
<div className="grid w-full max-w-sm justify-items-start gap-2">
<Button onClick={() => setOpen(false)} size="sm" variant="outline">
Collapse log panel
</Button>
<Collapsible onOpenChange={setOpen} open={open}>
<CollapsibleTrigger>Build log</CollapsibleTrigger>
<CollapsiblePanel>
<p className="font-hl-mono text-xs">build completed in 2.1s</p>
</CollapsiblePanel>
</Collapsible>
</div>
);
};Parts
| Part | Description |
|---|---|
CollapsiblePanel | The content the trigger shows and hides. Closed, it leaves the page unless keepMounted or hiddenUntilFound keeps it. |
CollapsibleTrigger | The button that opens and closes the panel. It says whether the panel is open with aria-expanded. |
Props
Prop
Type