Collapsible
An optional content section with a disclosure trigger.
Give your AI assistant this page as context.
Connect your library with MCPui/collapsibleUsage
Get this component from a saved library export or the connected CLI. The imports below refer to local files installed in your app.
Import styles/components.css, then styles/theme.css once. Wrap your app in ThemeScope from components/ui/utils so typography, focus and overlays share the theme. The installation guide covers runtime dependencies and React/Next.js setup.
import { Collapsible } from './components/ui/collapsible';
<Collapsible title="Advanced options">Additional settings for this workspace.</Collapsible>Design system
This component consumes your semantic colors, spacing, typography and shape tokens. Import the compiled styles and your theme once as described in Export.
Behavior and accessibility
- Provide meaningful labels for interactive controls.
- Connect action callbacks to your application logic.
- Verify keyboard navigation and contrast in your application.
Status: experimental during early access. Sample previews do not send emails, process payments or upload files to a service.
Source and props
This is the exported source, using the same implementation as the editor.
"use client";
import { Collapsible as Base } from "@base-ui/react/collapsible";
import type { ReactNode } from "react";
export function Collapsible({
title,
children,
defaultOpen = false,
open,
onOpenChange,
disabled = false,
keepMounted = false,
}: {
title: string;
children: ReactNode;
defaultOpen?: boolean;
open?: boolean;
onOpenChange?: (open: boolean) => void;
disabled?: boolean;
keepMounted?: boolean;
}) {
return (
<Base.Root
defaultOpen={defaultOpen}
open={open}
onOpenChange={onOpenChange}
disabled={disabled}
className="cr-collapsible"
>
<Base.Trigger
className="cr-button cr-collapsible-trigger"
data-variant="ghost"
>
{title}
<svg
width="16"
height="16"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth="1.75"
strokeLinecap="round"
strokeLinejoin="round"
aria-hidden="true"
>
<path d="m6 9 6 6 6-6" />
</svg>
</Base.Trigger>
<Base.Panel keepMounted={keepMounted} className="cr-collapsible-panel">
{children}
</Base.Panel>
</Base.Root>
);
}