Collapse

Collapse shows and hides content behind a title. It can be used to create accordion-like experiences where one or more panels are open at a time. It has no styles of its own, so it can match any UI.

Example Collapse 1
When the title is focused, this content will show.
Example Collapse 2
When the title is focused, this content will show.
Code Example
<Collapse>
  <CollapseTitle>Example Collapse 1</CollapseTitle>
  <CollapseContent>Focus the Collapse to show the content.</CollapseContent>
</Collapse>

Components

The Collapse components include the following:

Collapse

The Collapse component wraps the below components. Its behavior can be customized using the following props:

PropTypeDescription
open
boolean
forces the collapse to open
closed
boolean
forces the collapse to close
toggle
boolean
toggles the state on click
style
string
styles the collapse to either of the below prop names
    arrow
boolean
styles the collapse with a chevron up/down
    plus
boolean
styles the collapse with a plus/minus
value
any
specifies the value for use with Accordion

CollapseTitle

The CollapseTitle goes inside the Collapse and toggles the state when clicked.

CollapseContent

The CollapseContent holds content and will display when the Collapse is open.

Plain Styles

The Collapse has no background or border, by default. Everything is styleable with utility classes.

Unstyled Collapse 1
When the title is focused, this content will show.
Unstyled Collapse 2
When the title is focused, this content will show.

Open

Use the open prop to force the Collapse to stay open:

Open Collapse 1
When the title is focused, this content will show.
Open Collapse 2
When the title is focused, this content will show.
Code Example
<Collapse open>
  <CollapseTitle class="font-bold bg-base-300">
    Example Collapse Open
  </CollapseTitle>
  <CollapseContent class="bg-base-200">
    This content will always show.
  </CollapseContent>
</Collapse>

Close

Use the close prop to force the Collapse to stay closed:

Close Collapse 1
When the title is focused, this content will show.
Close Collapse 2
When the title is focused, this content will show.
Code Example
<Collapse close>
  <CollapseTitle class="font-bold bg-base-300">
    Example Collapse Open
  </CollapseTitle>
  <CollapseContent class="bg-base-200">
    This content will always show.
  </CollapseContent>
</Collapse>

Toggle

Use the toggle prop to toggle open/close state on click. The Collapse will remain open even when losing focus. This example also adds a background color to the entire Collapse using utility classes.

Toggle Content
Hello!
Toggle Content
Hello!
Toggle Content
Hello!
Toggle Content
Hello!
Code Example
<Collapse toggle class="bg-primary text-primary-content">
  <CollapseTitle>Toggle Content</CollapseTitle>
  <CollapseContent>Hello!</CollapseContent>
</Collapse>

Value

The value prop can be used with Accordion to control multiple Collapse components with a single v-model on the Accordion. See Accordion docs.