Back to Tooljet

Collapsible — Rocket Design Spec

frontend/src/components/ui/Rocket/Collapsible/Collapsible.spec.md

3.20.154-lts2.8 KB
Original Source

Collapsible — Rocket Design Spec

<!-- figma: https://www.figma.com/design/lOW96V8fTBx9J6yolOLhdC/01-Dashboards---Applications?node-id=4216-38603 --> <!-- synced: 2026-04-01 -->

Overview

Collapsible is a disclosure component — a trigger row that expands/collapses hidden content. Used inside modals, settings panels, and detail views to group secondary information.

Wraps Radix Collapsible primitives via shadcn.

Props (Collapsible — root)

PropTypeValuesDefault
variantstringbordered | ghostbordered
defaultOpenbooleanfalse
openboolean
onOpenChangefunction

Sub-components

ComponentWrapsStyling
CollapsibleRadix Collapsible.Rootvariant CVA (bordered vs ghost)
CollapsibleTriggerRadix Trigger (re-export)none — consumer styles the trigger content
CollapsibleContentRadix Contentpadding, animated height

Token Mapping

ElementVariantStateToolJet class
root containerbordereddefaulttw-border-solid tw-border tw-border-border-weak tw-rounded-lg
root containerghostdefaultno border, no bg
trigger rowalldefaulttw-flex tw-items-center tw-justify-between tw-w-full tw-cursor-pointer
trigger rowbordereddefaulttw-px-4 tw-py-3
trigger rowghostdefaulttw-py-2
trigger textalldefaulttw-font-title-default tw-text-text-default
trigger chevronalldefaulttw-text-icon-default tw-size-4
trigger chevronallopentw-rotate-180 (via data-[state=open])
content areabordereddefaulttw-px-4 tw-pb-3
content areaghostdefaulttw-py-2
content textalldefaulttw-font-body-default tw-text-text-default

Slots

  • trigger (required, ReactNode) — the clickable header content (label, count badge, etc.)
  • children (required, ReactNode) — the collapsible content area

CVA Shape

Shape B — variants only (bordered | ghost). No sizes.

Usage Pattern

jsx
<Collapsible variant="bordered">
  <CollapsibleTrigger>
    <span>Missing user groups (5)</span>
  </CollapsibleTrigger>
  <CollapsibleContent>
    <p>Group 1, Group 2, Group 3, Group 4, Group 5</p>
  </CollapsibleContent>
</Collapsible>

Notes

  • Radix handles open/close state, keyboard (Enter/Space), and aria-expanded automatically.
  • The chevron rotation is handled via data-[state=open]:tw-rotate-180 on the icon inside the trigger. Since the trigger is consumer-composed, Rocket provides a CollapsibleIcon helper that auto-rotates.
  • Animated height transition on CollapsibleContent via tw-overflow-hidden + CSS grid-template-rows animation (same pattern as shadcn accordion).
  • Typography uses tw-font-* plugin utilities.