Dashral Pro is hereSee pricing

Dashral

CollapsibleNew

One section that opens and closes under its title.

$ pnpm dlx shadcn@latest add @dashral/collapsible

Installation

$ pnpm dlx shadcn@latest add @dashral/collapsible

Adds the component, the components it builds on, its npm packages and the theme tokens it uses. Or by its full URL: https://dashral.com/r/collapsible.json

Usage

example.tsx
import { Input } from "@/components/dashral/input"
import { Collapsible } from "@/components/dashral/collapsible"

<Collapsible title="Advanced settings">
  <Input label="Slug" defaultValue={project.slug} />
</Collapsible>

Using the npm package? Import from @dashral/ui/components/collapsible instead, here and in the examples; the rest is the same.

Examples

Your own trigger

trigger takes a Button; open and onOpenChange control it.

Order summary

meta puts the total in the title's row; the lines fold under it.

API reference

Collapsible

Also takes every prop of Radix Collapsible(opens in a new tab).

PropTypeDefault
titleReactNode

Makes the trigger: a full-width button with a chevron.

—
triggerReactElement

Your own trigger in place of the title's, e.g. a Button.

—
metaReactNode

With title: at the end of its row, before the chevron, e.g. a count.

—
childrenReactNode

What opens and closes.

—
open / defaultOpen / onOpenChange

Control it yourself, or start it open.

—
disabledboolean

It can't be opened or closed.

false
classNames{ trigger, content }

Classes for each part.

—
classNamestring

Extra classes, merged with cn() so yours win.

—

Keyboard

KeysAction
EnterorSpaceOpen or close

Accessibility

  • The trigger has aria-expanded and aria-controls pointing at the content.

Motion

  • Opening, the height grows at a calm pace (--duration-considered) while the content fades in, dropping a little. Closing, the content fades out first while the height waits, then gathers speed (--ease-exit), so no line is cut through. The chevron turns on the spring.