Skip to Content
NarakUI

Collapsible

Show and hide a section of content with a height animation.

Basic

Without asChild, the trigger renders its own ghost button. The trigger carries data-state, so a group-data-[state=open] class can rotate the chevron.

  • nerdwallet.com
  • forbes.com/advisor
  • reddit.com/r/personalfinance

Card section

A titled section inside a Card, open by default. The trigger is the full header row.

  • Best travel credit cards for 2026Blog post · Edited 2 hours ago
  • How Profound measures AI visibilityLanding page · Edited yesterday
  • Q3 answer engine reportReport · Edited 3 days ago

Advanced settings

With asChild, any Button can be the trigger. Use it to tuck rarely used form fields away.

Separate paths with commas.

Accordion

There is no separate accordion primitive. Control several collapsibles from one piece of state so only one stays open.

A citation is a link an answer engine shows next to its response. We record the domain, URL and position.

Every tracked prompt runs daily on each answer engine in your plan, from the regions you selected.

ChatGPT, Perplexity, Google AI Overviews, Gemini, Claude and Microsoft Copilot.

Installation

pnpm dlx shadcn@latest add @narakui/collapsible

Add "@narakui": "https://ui.narakcode.dev/r/{name}.json" to components.json, or install directly from https://ui.narakcode.dev/r/collapsible.json.

Usage

import { Button } from '@/components/ui/button';
import { Collapsible } from '@/components/ui/collapsible';

<Collapsible.Root>
  <Collapsible.Trigger asChild>
    <Button iconEnd="chevron-down">Toggle content</Button>
  </Collapsible.Trigger>
  <Collapsible.Content>Content to collapse/expand</Collapsible.Content>
</Collapsible.Root>

Without asChild, Collapsible.Trigger renders its own ghost text button and wraps the children in a span.

Collapsible.Root Properties

PropTypeDefaultDescription
defaultOpenbooleanfalseWhether the collapsible is open by default
openboolean—Controlled open state
onOpenChange(open: boolean) => void—Callback when open state changes
disabledbooleanfalseWhether the collapsible is disabled
classNamestring—Additional CSS classes for the root element

Collapsible.Trigger Properties

PropTypeDefaultDescription
asChildbooleanfalseMerges trigger behavior into the single child, usually a Button, instead of rendering the default ghost trigger
showHoverBackgroundbooleantrueShows the hover background on the default trigger. Ignored with asChild.
spanClassNamestring—Additional classes for the inner span of the default trigger. Ignored with asChild.
classNamestring—Additional CSS classes for the trigger

Collapsible.Content Properties

PropTypeDefaultDescription
forceMounttrue—Keeps the content mounted while closed
classNamestring—Additional CSS classes for the content