Skip to content
synccn

Collapsible

A single section that expands and collapses.

Michael starred 4 repositories

synccn/ui
  • synccn/cli
  • synccn/themes
  • synccn/blocks

Installation

$ pnpm dlx shadcn@latest add @synccn/collapsible

First time in this project? Connect synccn with one command.

Usage

import { Collapsible } from "@/components/ui/collapsible";<Collapsible trigger="Show more">…</Collapsible>

API reference

Generated from the component's TypeScript types, so it always matches the code.

Collapsible

One section that expands and collapses with a height animation.

  • open
    boolean

    Controlled open state.

  • defaultOpen
    boolean

    Default false

    Initial state when uncontrolled.

  • onOpenChange
    (open: boolean) => void

    Called when it opens or closes.

  • triggerrequired
    | React.ReactNode | ((state: { open: boolean; toggle: () => void; "aria-expanded": boolean; "aria-controls": string }) => React.ReactNode)

    Trigger content, or a render function for a custom trigger.

  • children
    React.ReactNode

    Content to render.

  • className
    string

    Extra classes for the root element.

Dependencies

Read from the component's imports when the site builds. The CLI installs all of these for you.

Helpers

  • lib/utilscn (merges class names)
  • lib/hooksuseControllable (works controlled or uncontrolled)

npm packages

Accessibility

From the source

Read from this component's code when the site builds, so it can't drift.

  • ARIA attributes: aria-controls, aria-expanded