Collapsible

Collapsible components allow users to toggle the visibility of content sections, providing a simple way to show or hide information on demand.

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

Examples

Showcase

Basic collapsible component with a trigger button that expands and collapses content.

import {Component} from "@angular/core"

import {ButtonModule} from "@qualcomm-ui/angular/button"
import {CollapsibleModule} from "@qualcomm-ui/angular/collapsible"

@Component({
  imports: [CollapsibleModule, ButtonModule],
  selector: "collapsible-showcase-demo",
  template: `
    <div class="flex flex-col items-center" q-collapsible-root>
      <button
        class="my-3"
        emphasis="primary"
        q-button
        q-collapsible-trigger
        variant="fill"
      >
        Toggle
      </button>
      <div q-collapsible-content>
        <div
          class="border-neutral-01 box-border flex h-48 w-72 flex-col rounded-sm border p-4"
        >
          Content
        </div>
      </div>
    </div>
  `,
})
export class CollapsibleShowcaseDemo {}

Controlled State

Control the collapsible's open/closed state using the open and openChanged properties.

Content
import {Component, signal} from "@angular/core"

import {ButtonModule} from "@qualcomm-ui/angular/button"
import {CollapsibleModule} from "@qualcomm-ui/angular/collapsible"

@Component({
  imports: [CollapsibleModule, ButtonModule],
  selector: "collapsible-controlled-demo",
  template: `
    <div
      class="flex flex-col items-center"
      q-collapsible-root
      [open]="open()"
      (openChanged)="open.set($event)"
    >
      <button
        class="my-3"
        emphasis="primary"
        q-button
        q-collapsible-trigger
        variant="fill"
      >
        Toggle
      </button>
      <div q-collapsible-content>
        <div
          class="border-neutral-01 box-border flex h-48 w-72 flex-col rounded-sm border p-4"
        >
          Content
        </div>
      </div>
    </div>
  `,
})
export class CollapsibleControlledDemo {
  readonly open = signal(true)
}

Explorer

Component Anatomy

Hover to highlight, click to view API

API

q-collapsible-root

PropTypeDefault
The initial open state of the collapsible when rendered. Use when you don't need to control the open state of the collapsible.
boolean
The document's text/writing direction.
'ltr' | 'rtl'
"ltr"
Whether the collapsible is disabled.
boolean
A root node to correctly resolve the Document in custom environments. i.e., Iframes, Electron.
() =>
| ShadowRoot
| Document
| Node
Whether to defer creating content until the first expansion. Apply shouldRender() from the content directive to its template.
boolean
false
The controlled open state of the collapsible
boolean
Whether to destroy content after the collapse animation finishes. Apply shouldRender() from the content directive to its template.
boolean
false
Function called when the animation ends in the closed state
void
Function called when open changes.
boolean
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
() =>
| ShadowRoot
| Document
| Node
Description
A root node to correctly resolve the Document in custom environments. i.e., Iframes, Electron.
Type
boolean
Description
Whether to defer creating content until the first expansion. Apply shouldRender() from the content directive to its template.
Type
boolean
Description
The controlled open state of the collapsible
Type
boolean
Description
Whether to destroy content after the collapse animation finishes. Apply shouldRender() from the content directive to its template.
Type
void
Description
Function called when the animation ends in the closed state
Type
boolean
Description
Function called when open changes.

q-collapsible-trigger

q-collapsible-content

Updated by Olaf Kappes