Components

Collapsible

An animated React collapsible built on shadcn/ui and Radix: the drop-in Collapsible eases its height open and fades content in, plus a spring-physics Motion collapsible with a rotating chevron and show-more blocks that expand clamped text and long lists smoothly.

  • Drop-in shadcn API
  • Radix Collapsible
  • Height animation
  • Show more
  • prefers-reduced-motion
  1. Order confirmed
  2. Packed at the warehouse
  3. Handed to the courier
Free returns within 30 days. Print a label from your account and drop the parcel at any partner location — refunds land within three business days of us receiving it.

Installation

$ npx shadcn@latest add https://duskui.com/r/collapsible.json

Replaces components/ui/collapsible.tsx with the same exports. The height animation uses Radix's --radix-collapsible-content-height with the collapsible-down / collapsible-up keyframes from tw-animate-css, which shadcn projects already include.

Usage

details.tsx
import {
  Collapsible,
  CollapsibleContent,
  CollapsibleTrigger,
} from "@/components/ui/collapsible"

export function Details() {
  return (
    <Collapsible>
      <CollapsibleTrigger>Can I use this in my project?</CollapsibleTrigger>
      <CollapsibleContent>Yes. Free for personal and commercial use.</CollapsibleContent>
    </Collapsible>
  )
}

Examples

Default

A controlled Collapsible with a Button trigger (asChild). The extra rows grow in and fade as the panel opens, and close quicker than they open; nothing below them jumps.

@ada starred 4 repositories

duskui/ui

Blocks

Ready-made variations composed from the base component with Motion. Each installs on its own and pulls in its dependencies automatically.

Motion Collapsible

The panel eases its height open while the content fades in after it, and the chevron turns. Open panels get a slightly brighter outline. Closed content stays in the DOM as inert, so it's indexed by search engines but skipped by keyboard and screen readers.

  1. Order confirmed
  2. Packed at the warehouse
  3. Handed to the courier
Free returns within 30 days. Print a label from your account and drop the parcel at any partner location — refunds land within three business days of us receiving it.
$ npx shadcn@latest add https://duskui.com/r/motion-collapsible.json
PropTypeDefaultDescription
open / defaultOpen / onOpenChangebooleanfalseOn MotionCollapsible: controlled or uncontrolled state.
borderedbooleantrueOn MotionCollapsible: card outline that brightens while open.
disabledbooleanfalseOn MotionCollapsible: prevent toggling.
iconReactNode | null—On MotionCollapsibleTrigger: replaces the chevron (still rotates); null hides it.
classNamestring—On MotionCollapsibleContent: styles the inner padded wrapper.

Show More

ShowMore clamps long text to a preview that fades out at the bottom. The height springs to auto and the fade mask dissolves as it opens; the toggle hides itself when the content already fits. The full text is always in the DOM, so it stays indexable.

Why we build at dusk

The best interfaces feel calm. They answer before you ask, move only when movement means something, and get out of the way the rest of the time.

DuskUI started as a set of internal components for a dark-first product. Every piece had to survive a keyboard-only pass, a screen reader pass and a reduced-motion pass before it shipped.

Springs replaced durations, because springs can be interrupted without a jump. Heights animate to their natural size, so nothing below them ever snaps into place.

$ npx shadcn@latest add https://duskui.com/r/show-more.json
PropTypeDefaultDescription
collapsedHeightnumber120Height of the clamped preview, in px.
expanded / defaultExpanded / onExpandedChangebooleanfalseControlled or uncontrolled state.
moreLabel / lessLabelReactNode"Show more" / "Show less"Button text. Both share one grid cell, so the button never resizes.
contentClassNamestring—Classes for the content wrapper (typography, spacing).

Show More List

ShowMoreList (same file) shows the first items of a list and reveals the rest with a staggered spring — each row grows in, fades and slides up, then folds away in reverse. It stays one semantic ul, and the button says how many items are hidden.

Changelog

  • 2.4.0Menubar, Drawer and Chart primitives
  • 2.3.2Resizable handles highlight while dragging
  • 2.3.1Collapsible content fades as it opens
$ npx shadcn@latest add https://duskui.com/r/show-more.json
PropTypeDefaultDescription
items / renderItemT[] / (item: T, index: number) => ReactNode—The data and how to render one item inside its li.
getKey(item: T, index: number) => Key—Stable key per item. Defaults to the index.
initialCountnumber3Items visible before expanding.
expanded / defaultExpanded / onExpandedChangebooleanfalseControlled or uncontrolled state.
moreLabel / lessLabel(hidden: number) => ReactNode / ReactNode"Show N more" / "Show less"Button text.
listClassName / itemClassNamestring—Classes for the ul and every li.

API Reference

Same parts as shadcn/ui: Collapsible, CollapsibleTrigger and CollapsibleContent, each forwarding its Radix Collapsible props. className on CollapsibleContent lands on the animated element, like shadcn.

PropTypeDefaultDescription
open / defaultOpen / onOpenChangeboolean—On Collapsible: controlled or uncontrolled state.
disabledbooleanfalseOn Collapsible: prevent toggling.
asChildbooleanfalseOn CollapsibleTrigger: render your own Button.
forceMounttrue—On CollapsibleContent: keep it mounted while closed (for your own animations).

Accessibility

  • Built on Radix Collapsible: the trigger is a button with aria-expanded and aria-controls pointing at the content.
  • The Motion block keeps closed content mounted but inert, so it can't be focused or read until opened.
  • Show More buttons expose aria-expanded / aria-controls; ShowMoreList's label states how many items are hidden.
  • Under prefers-reduced-motion panels open and close instantly, and list rows appear without sliding.