Skip to content
Klarhimmel UI

Collapsible

npx shadcn add @klarhimmel/collapsible

Examples

  • Basic

  • Controlled

  • Disabled

DetailsAbout, usage, props and more

One button that shows or hides extra content below it.

When to use

  • Use for

    One optional region the person can open: a policy, advanced options.

  • Not for

    A list of regions. Use Accordion.

  • Pairs with

    Text, Field, Card.

Preview

collapsible.tsx
import { Theme } from '@/components/klarhimmel/theme/style';
import { Collapsible } from '@/components/klarhimmel/ui/collapsible';

export default function Example() {
  return (
    <Theme theme="brand">
      <Collapsible title="Show the cancellation policy">
        Free until 48 hours before arrival.
      </Collapsible>
    </Theme>
  );
}

Import

Import

import { Collapsible } from '@/components/klarhimmel/ui/collapsible';
Files
collapsible.tsx, in components/klarhimmel/ui/. With it: theme, utils. npm: lucide-react.
Render in
Render it inside <Theme>, once near the root of your app. Tokens and fonts are scoped to it, so outside it the component is unstyled.

Props

PropTypeDefaultDescription
titleReactNoderequiredThe always-visible line that opens and closes the rest.
childrenReactNoderequired
openboolean-Controlled or uncontrolled state.
defaultOpenboolean-Controlled or uncontrolled state.
onOpenChange(open: boolean) => void-Controlled or uncontrolled state.
disabledboolean-The button does nothing.
classNamestring-Extra classes, merged after the component's own.

Accessibility

KeyDoes
Enter / SpaceOpens or closes the region
TabMoves focus; the ring is always visible