Skip to content

Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.

2.8 KB
Raw Blame

description: >- An interactive component which expands/collapses a panel.

Collapsible

Features

How to use the Radix UI Collapsible

The Collapsible Component is in the "Components Panel" under the "Radix" section. Click on it or drag it onto the canvas. The Collapsible will populate a template that's easy to adjust for your needs.

Components panel Radix group with the Collapsible card highlighted

Radix UI Collapsible component within Webstudio

The Collapsible component consists of three main parts:

  1. Collapsible: The root component that controls the collapsible behavior.
  2. Collapsible Trigger: The button that toggles the collapsible.
  3. Collapsible Content: The component that contains the collapsible content.

Customizing the Collapsible

To customize the Collapsible component:

  1. Collapsible Trigger: Modify the trigger element to change what users click to expand/collapse the content. This can be text, an icon, or any combination of elements.
  2. Collapsible Content: Edit the content section to add whatever elements you want to show/hide when the collapsible is toggled.
  3. Styling: Any of the three components can be styled to match your design requirements.

Keep closed content in the HTML

Select Collapsible Content and enable Force Mount to keep its content in the HTML while the Collapsible is closed. New Collapsible components enable this setting by default. Disable it to remove closed content from the HTML.

When Force Mount is enabled, add a closed-state CSS rule such as height: 0 for [data-state="closed"]. Animation-only examples can leave the content visible because they assume Radix unmounts closed content.

Radix temporarily sets inline transition-duration: 0s and animation-name: none while it measures content height. This can suppress the first open animation, so test both the first open and later open/close cycles.

Using Collapsible for UI Patterns

The Collapsible component is useful for various UI patterns:

  • FAQ sections
  • "Show more" content sections
  • Settings or preferences panels
  • Mobile navigation menus
  • Detail views that can be expanded/collapsed

Related

  • Accordion – Multiple collapsible sections in a group
  • Tabs – Organize content into switchable panels
  • Dialog – Modal window for focused content
  • Sheet – Sliding panel from screen edge