ikascom

Collapse

Component

About

An animated panel that expands and collapses its content between zero and auto height, fading content in as it opens and out before it closes.

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Collapse to your project and fits it to your theme.

Code

How Collapse is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

"use client";

import * as React from "react";

import { Button } from "@/components/ui/button";
import { Collapse } from "@/components/ui/collapse";

export default function CollapseDemo() {
  const [open, setOpen] = React.useState(false);
  const id = React.useId();

  return (
    <div className="w-full max-w-md space-y-4">
      <Button
        variant="outline"
        size="sm"
        aria-expanded={open}
        aria-controls={id}
        onClick={() => setOpen((o) => !o)}
      >
        {open ? "Hide details" : "Show details"}
      </Button>
      <Collapse
        open={open}
        id={id}
        className="rounded-md border p-4 text-sm text-muted-foreground"
      >
        This content animates its height open and closed, fading in after the
        space opens and fading out before it closes.
      </Collapse>
    </div>
  );
}

Dependencies

More by ikascom

View all
  • Animated Number

    Animated Number

    16
  • Action Bar

    Action Bar

    3
  • Layout

    Layout

  • Launchpad Setup Checklist

    Launchpad Setup Checklist