For AI agents: the complete documentation index is available at https://rickyshin93.github.io/tao-ui/llms.txt, the full documentation bundle is available at https://rickyshin93.github.io/tao-ui/llms-full.txt, and this page is available as Markdown at https://rickyshin93.github.io/tao-ui/components/collapse.md.
v0.0.57
  • English
  • Collapse

    Data Display@rockshin/tao-ui

    Item-based panels with built-in headers, expand icons and content regions; supports independent panels and accordions.

    When to use

    Group settings, explanations and secondary details. Use accordion to keep one panel open at a time. Make required information easy to discover.

    Examples

    Basic panels

    Pass items for complete panels. Multiple panels can be expanded by default.

    Keep project goals, progress and recent changes together.
    TSX

    Accordion

    Open one panel at a time. Clicking the active panel again closes it.

    Keep project goals, progress and recent changes together.
    TSX

    Controlled expansion

    Coordinate expansion through activeKey and onChange. Callbacks always receive an array of string keys.

    Keep project goals, progress and recent changes together.
    Expanded: 1
    TSX

    Three sizes

    Choose small, medium or large; size also inherits from TaoProvider.

    Keep project goals, progress and recent changes together.
    Keep project goals, progress and recent changes together.
    Keep project goals, progress and recent changes together.
    TSX

    Borderless and ghost

    bordered={false} removes the outer border; ghost also removes the background and separators.

    Keep project goals, progress and recent changes together.
    Keep project goals, progress and recent changes together.
    TSX

    Trigger modes and disabled panels

    Toggle with the whole header, only the icon, or disable a panel. Arrow-free headers remain clickable.

    Icon only
    TSX

    Extra actions and end icon

    Put independent actions in extra. Clicking them does not toggle the panel.

    Edit count: 0
    TSX

    Nested panels and custom icons

    Nested groups keep independent state. Custom icons receive isActive.

    TSX

    Retain or destroy content

    Bodies mount on first expansion and retain inputs when closed. destroyOnHidden unmounts closed bodies; an item with forceRender stays mounted.

    TSX

    Panels on a phone

    Long titles wrap while icons and extra actions stay usable. Phone and desktop selection follows the shared preview state.

    390 × 640
    TSX

    Migration and composition

    Rename Collapsible / @rockshin/tao-ui/collapsible to Collapse / @rockshin/tao-ui/collapse. Prefer items over hand-built headers and bodies. Collapse.Trigger / Collapse.Content remain available for custom single disclosures with open / onOpenChange; item panels use activeKey / onChange. Do not mix the two state APIs.

    API

    Collapse

    PropertyDescriptionTypeDefault Value
    itemsComplete panels with built-in headers, icons and content styling.CollapseItem[] | undefined-
    onChangeCalled with normalized string keys, including in accordion mode.((activeKeys: string[]) => void) | undefined-
    accordionAllow at most one active panel; clicking it again closes it.boolean | undefined-
    destroyOnHiddenUnmount closed bodies unless the item has forceRender.boolean | undefined-
    openControlled open state.boolean | undefined-
    defaultOpenUncontrolled initial open state. Defaults to false.boolean | undefined-
    disabledDisable the trigger. Falls back to TaoProvider's disabled.boolean | undefined-
    classNameMerged into the root element.string | undefined-
    styleAdditional styleCSSProperties | undefined-

    Collapse.Trigger

    PropertyDescriptionTypeDefault Value
    asChildRender the child element as the trigger instead of a default button.boolean | undefined-
    classNameAdditional css classstring | undefined-
    styleAdditional styleCSSProperties | undefined-

    Collapse.Content

    PropertyDescriptionTypeDefault Value
    classNameAdditional css classstring | undefined-
    styleAdditional styleCSSProperties | undefined-

    CollapseItem

    PropertyDescription
    keyUnique string / number key; callbacks normalize it to a string
    label / childrenHeader label and panel body
    extraIndependent header actions
    collapsibleheader / icon / disabled
    showArrowDefaults to true; false cannot be combined with collapsible="icon"
    forceRenderDefaults to false; mount early and keep the body mounted
    className / styleItem container styling
    classNames / stylesSemantic header/body styles; item styles override group values