mayurrawte

Accordion

Navigation 1

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
  • MCP Scope Inspector

    MCP Scope Inspector

    2
  • Feedback Buttons

    Feedback Buttons

    2
  • Tooltip

    Tooltip

    2
  • Skeleton

    Skeleton

    2
  • MCP Resource Browser

    MCP Resource Browser

  • MCP App Frame

    MCP App Frame

  • Counter

    Counter

  • Dropdown Menu

    Dropdown Menu

More in Navigation

View all
  • Liquid Glass Expandable Sidebar

    Liquid Glass Expandable Sidebar

    76
  • Footer with Big Wordmark

    Footer with Big Wordmark

    40
  • Sidebar

    Sidebar

    392
  • Oversized 404 Numeral

    Oversized 404 Numeral

    78
  • Navbar with Theme Toggle

    Navbar with Theme Toggle

    67
  • NavBar

    NavBar

    2
  • Pagination

    Pagination

    109
  • Tabs like bookmark

    Tabs like bookmark

    82