mayurrawte

Accordion

Navigation 2

About

A headless, render-prop accordion for building collapsible content sections like FAQs or settings panels, with keyboard navigation and single or multiple expand modes.

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

Code

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

Usage.tsx

import {
  Accordion,
  AccordionItem,
  AccordionTrigger,
  AccordionContent,
} from "@/components/ui/accordion";

const items = [{ value: "transport" }, { value: "auth" }, { value: "tools" }];

const descriptions: Record<string, string> = {
  transport:
    "mcp-elements speaks both stdio and streamable HTTP. The client negotiates the transport during the initialize handshake.",
  auth: "OAuth 2.1 with PKCE is supported out of the box. Tokens are scoped per-server and refreshed automatically.",
  tools:
    "Tools are listed via tools/list and invoked with tools/call. Schemas are validated against the advertised JSON Schema.",
};

export default function AccordionDemo() {
  return (
    <Accordion items={items} collapsible className="w-full max-w-md">
      {({ expandedValues, getTriggerProps, getContentProps }) => (
        <>
          {items.map((item) => (
            <AccordionItem key={item.value}>
              <AccordionTrigger
                {...getTriggerProps(item.value, expandedValues)}
                isExpanded={expandedValues.includes(item.value)}
              >
                {item.value}
              </AccordionTrigger>
              <AccordionContent
                {...getContentProps(item.value, expandedValues)}
              >
                {descriptions[item.value]}
              </AccordionContent>
            </AccordionItem>
          ))}
        </>
      )}
    </Accordion>
  );
}

Dependencies

More by mayurrawte

View all
  • Feedback Buttons

    Feedback Buttons

    4
  • Streaming Text

    Streaming Text

    4
  • MCP Scope Inspector

    MCP Scope Inspector

    2
  • Tooltip

    Tooltip

    2
  • Skeleton

    Skeleton

    2
  • Loader

    Loader

    2
  • Dialog

    Dialog

    1
  • Select Dropdown

    Select Dropdown

    1

More in Navigation

View all
  • Footer with Big Wordmark

    Footer with Big Wordmark

    133
  • Liquid Glass Expandable Sidebar

    Liquid Glass Expandable Sidebar

    368
  • Meniscus — Liquid Bottom Navigation Bar

    Meniscus — Liquid Bottom Navigation Bar

    1
  • Sidebar

    Sidebar

    431
  • Pagination with Ellipsis

    Pagination with Ellipsis

    31
  • Button Breadcrumb

    Button Breadcrumb

    43
  • Pagination

    Pagination

    118
  • Navbar

    Navbar

    80