Skip to content

Search documentation

Search guides, examples, and component APIs.

Quick links
↑↓ NavigateEnter OpenEsc Close
Get started

Documentation navigation

Components / Layout

Collapsible

A controlled or uncontrolled disclosure region with native trigger semantics.

Last changed in version 0.13.0: Add avatar groups and chips, expand the block gallery, and improve component colors, spacing, and motion.

Interactive showcase

Owner
Ana Martins
Status
In review
Updated
12 min ago

Install

Run in your project
bunx --bun @getweini/cli@latest add collapsible

Start with this example

Import the files copied by the install command, then place the component in your Vue template. The text and values in the example belong to your app; change them to fit your task.

Owner: Ana Martins

Status: In review

Vue
<script setup lang="ts">
import Collapsible from './components/ui/collapsible/Collapsible.vue'
import CollapsibleContent from './components/ui/collapsible/CollapsibleContent.vue'
import CollapsibleTrigger from './components/ui/collapsible/CollapsibleTrigger.vue'
</script>

<template>
  <Collapsible default-open>
    <CollapsibleTrigger v-slot="{ open }">
      <span class="inline-flex items-center gap-2">
        Project details
        <svg
          aria-hidden="true"
          viewBox="0 0 16 16"
          class="ui-motion size-4 fill-none stroke-current"
          :class="{ 'rotate-180': open }"
        >
          <path d="m4 6 4 4 4-4" stroke-width="1.5" stroke-linecap="round" />
        </svg>
      </span>
    </CollapsibleTrigger>
    <CollapsibleContent>
      <p>Owner: Ana Martins</p>
      <p>Status: In review</p>
    </CollapsibleContent>
  </Collapsible>
</template>

Trigger and content have stable ARIA relationships. Closed content remains inert and the transition respects reduced motion.

When to use it

Optional details

Hide secondary metadata until someone asks to inspect it.

Compact filters

Let readers open advanced filters without leaving the page.

More examples

Project details

Use the default-open state for information that usually matters.

Project details
<script setup lang="ts">
import Collapsible from './components/ui/collapsible/Collapsible.vue'
import CollapsibleContent from './components/ui/collapsible/CollapsibleContent.vue'
import CollapsibleTrigger from './components/ui/collapsible/CollapsibleTrigger.vue'
</script>

<template>
  <Collapsible default-open>
    <CollapsibleTrigger>Project details</CollapsibleTrigger>
    <CollapsibleContent>
      <p>Owner: Ana Martins</p>
      <p>Status: In review</p>
    </CollapsibleContent>
  </Collapsible>
</template>

Controlled filters

Use the open model when another control also changes disclosure state.

Controlled filters
<script setup lang="ts">
import { ref } from 'vue'
import Collapsible from './components/ui/collapsible/Collapsible.vue'
import CollapsibleContent from './components/ui/collapsible/CollapsibleContent.vue'
import CollapsibleTrigger from './components/ui/collapsible/CollapsibleTrigger.vue'

const open = ref(false)
</script>

<template>
  <Collapsible v-model:open="open">
    <CollapsibleTrigger>Advanced filters</CollapsibleTrigger>
    <CollapsibleContent>
      <label>Owner&nbsp;<input name="owner"></label>
    </CollapsibleContent>
  </Collapsible>
</template>

Complete API

Every public prop, model, event, slot, and exposed member of the installed Vue parts is listed below. “Not set” means you can leave that value out; “Required” means you must provide it. Native HTML attributes also work where the component uses a native element.

Collapsible

Complete API for Collapsible
NameType or signatureDefaultWhat it does
openmodelboolean | undefinedNot setCurrent open state. Use v-model:open to keep it in sync with your page.
defaultOpenpropboolean | undefinedfalseStarting open state when the parent does not control open.
disabledpropboolean | undefinedfalsePrevent interaction and show the disabled state.
update:openevent[open: boolean]—Requests a new open value from the parent.
openChangeevent[open: boolean]—Emitted after this value or state changes.
defaultslot(props: { open: boolean; setOpen: (open: boolean) => void; }) => unknownRequiredContent shown inside Collapsible.
openexposed() => void—Open this component from application code.
closeexposed() => void—Close this component from application code.
toggleexposed() => void—Access toggle from a component template ref.
focusexposed() => void | undefined—Move keyboard focus to this control.

CollapsibleContent

Complete API for CollapsibleContent
NameType or signatureDefaultWhat it does
defaultslot(props: { open: boolean; }) => unknownRequiredContent shown inside CollapsibleContent.

CollapsibleTrigger

Complete API for CollapsibleTrigger
NameType or signatureDefaultWhat it does
disabledpropboolean | undefinedfalsePrevent interaction and show the disabled state.
asChildpropboolean | undefinedNot setUse one child element as the control instead of adding another wrapper.
defaultslot(props: { open: boolean; }) => unknownRequiredContent shown inside CollapsibleTrigger.
Public type definitions
Public types
// packages/frameworks/vue/components/collapsible/types.ts
// ------- TYPES -------

export interface CollapsibleProps {
  open?: boolean
  defaultOpen?: boolean
  disabled?: boolean
}

export interface CollapsibleTriggerProps {
  disabled?: boolean
  asChild?: boolean
}

Implementation notes

  • Put only secondary information in a closed disclosure; primary actions should stay visible.
  • Use v-model:open when the rest of the application must observe or change disclosure state.

Accessibility and localization

  • The trigger has a stable relationship to its content, and closed content is inert.

Source contract and editing guidance