Collapsible

import {Collapsible} from "@qualcomm-ui/react/collapsible"

Examples

Showcase

Basic collapsible component with a trigger button that expands and collapses content. The trigger uses the render prop to render as another component like our Button.

Controlled State

Control the collapsible's open/closed state using the open and onOpenChange props. This example demonstrates programmatic control with a close button inside the content.

API

<Collapsible.Root>

Groups all parts of the collapsible. Renders a <div> element by default.
PropTypeDefault
React children prop.
The initial open state of the collapsible when rendered. Use when you don't need to control the open state of the collapsible.
boolean
false
The document's text/writing direction.
'ltr' | 'rtl'
'ltr'
Whether the collapsible is disabled.
boolean
A root node to correctly resolve document in custom environments. i.e., Iframes, Electron.
    () =>
    | Node
    | ShadowRoot
    | Document
    The callback invoked when the exit animation completes.
      () => void
      Function invoked when the collapsible opens or closes
      • openThe next value.
      (
      open: boolean,
      ) => void
      The controlled open state of the collapsible
      boolean
      Allows you to replace the component's HTML element with a different tag or component. Learn more
      | ReactElement
      | ((
      props: object,
      ) => ReactElement)
      Description
      React children prop.
      Type
      boolean
      Description
      The initial open state of the collapsible when rendered. Use when you don't need to control the open state of the collapsible.
      Type
      'ltr' | 'rtl'
      Description
      The document's text/writing direction.
      Type
      boolean
      Description
      Whether the collapsible is disabled.
      Type
      () =>
      | Node
      | ShadowRoot
      | Document
      Description
      A root node to correctly resolve document in custom environments. i.e., Iframes, Electron.
        Type
        () => void
        Description
        The callback invoked when the exit animation completes.
          Type
          (
          open: boolean,
          ) => void
          Description
          Function invoked when the collapsible opens or closes
          • openThe next value.
          Type
          boolean
          Description
          The controlled open state of the collapsible
          Type
          | ReactElement
          | ((
          props: object,
          ) => ReactElement)
          Description
          Allows you to replace the component's HTML element with a different tag or component. Learn more

          <Collapsible.Trigger>

          A button that opens and closes the collapsible content panel. Renders a <button> element by default.
          PropType
          React children prop.
          id attribute. If omitted, a unique identifier will be automatically generated for accessibility.
          string
          Allows you to replace the component's HTML element with a different tag or component. Learn more
          | ReactElement
          | ((
          props: object,
          ) => ReactElement)
          Description
          React children prop.
          Type
          string
          Description
          id attribute. If omitted, a unique identifier will be automatically generated for accessibility.
          Type
          | ReactElement
          | ((
          props: object,
          ) => ReactElement)
          Description
          Allows you to replace the component's HTML element with a different tag or component. Learn more

          <Collapsible.Content>

          A panel with collapsible contents. Renders a <div> element by default.
          PropType
          React children prop.
          id attribute. If omitted, a unique identifier will be automatically generated for accessibility.
          string
          Allows you to replace the component's HTML element with a different tag or component. Learn more
          | ReactElement
          | ((
          props: object,
          ) => ReactElement)
          Description
          React children prop.
          Type
          string
          Description
          id attribute. If omitted, a unique identifier will be automatically generated for accessibility.
          Type
          | ReactElement
          | ((
          props: object,
          ) => ReactElement)
          Description
          Allows you to replace the component's HTML element with a different tag or component. Learn more