---
layout: ~/layouts/MdxDocLayout.astro
title: "Collapsible"
description: "A vertically stacked set of interactive headings that each reveal a section of content."
sourceFile: "components/collapsible"
baseUIComponent: "collapsible"
---

import ComponentExample from "~/components/docs/ComponentExample.astro";
import ComponentSection from "~/components/docs/ComponentSection.astro";
import CodeBlock from "~/components/docs/CodeBlock.astro";
import Heading from "~/components/docs/Heading.astro";
import PropsTable from "~/components/docs/PropsTable.astro";
import {
  CollapsibleHeroDemo,
  CollapsibleBasicDemo,
  CollapsibleMultipleDemo,
} from "~/components/demos/CollapsibleDemo";

<ComponentSection>
  <ComponentExample
    code={`<Collapsible label="What is Kumo?">
  Kumo is Cloudflare's new design system.
</Collapsible>`}
  >
    <CollapsibleHeroDemo client:load />
  </ComponentExample>
</ComponentSection>

<ComponentSection>
  <Heading level={2}>Installation</Heading>
  <Heading level={3}>Barrel</Heading>
  <CodeBlock
    code={`import { Collapsible } from "@cloudflare/kumo";`}
    lang="tsx"
  />
  <Heading level={3}>Granular</Heading>
  <CodeBlock
    code={`import { Collapsible } from "@cloudflare/kumo/components/collapsible";`}
    lang="tsx"
  />
</ComponentSection>

<ComponentSection>
  <Heading level={2}>Usage</Heading>
  <CodeBlock code={`import { Collapsible } from "@cloudflare/kumo";

export default function Example() {
  return (
    <Collapsible label="Question">
      Answer content goes here.
    </Collapsible>
  );
}`} lang="tsx" />
</ComponentSection>

<ComponentSection>
  <Heading level={2}>Examples</Heading>

<Heading level={3}>Single Item</Heading>
<ComponentExample
  code={`<Collapsible label="What is Kumo?">
  Kumo is Cloudflare's new design system.
</Collapsible>`}
>
  <CollapsibleBasicDemo client:load />
</ComponentExample>

  <Heading level={3}>Multiple Items</Heading>
  <ComponentExample code={`<div className="space-y-2">

  <Collapsible label="What is Kumo?">
    Kumo is Cloudflare's new design system.
  </Collapsible>
  <Collapsible label="How do I use it?">
    Install the components and import them into your project.
  </Collapsible>
  <Collapsible label="Is it open source?">
    Check the repository for license information.
  </Collapsible>
</div>`}>
    <CollapsibleMultipleDemo client:load />
  </ComponentExample>
</ComponentSection>

<ComponentSection>
  <Heading level={2}>API Reference</Heading>
  <PropsTable component="Collapsible" />
</ComponentSection>
