Veil UI
Components

Collapsible

A single show/hide section built on Radix Collapsible.

Installation

$ npx veil-ui@latest add collapsible

Usage

import {
  Collapsible,
  CollapsibleContent,
  CollapsibleTrigger,
} from "@/components/ui/collapsible";

<Collapsible>
  <CollapsibleTrigger>Toggle details</CollapsibleTrigger>
  <CollapsibleContent>Hidden details</CollapsibleContent>
</Collapsible>;

Examples

Basic

Recent deployments

Default open

Environment variables
DATABASE_URL=postgres://…
NEXT_PUBLIC_SITE_URL=https://veil-ui.dev

API reference

  • Collapsible supports controlled open / onOpenChange and defaultOpen.
  • CollapsibleTrigger is a button with aria-expanded managed by Radix.
  • CollapsibleContent removes its children from the DOM when closed.

Accessibility

  • The trigger announces its expanded state and controls the content region.
  • Enter and Space toggle it; the trigger stays focusable throughout.
  • Use Accordion when several sections share a heading pattern.

Vue and plain HTML

This component also ships for Vue (Reka UI) and plain HTML. Install it with npx veil-ui add collapsible --framework vue or switch the framework in components.json.

<script setup lang="ts">
import { CollapsibleContent } from "reka-ui";

import { cn } from "@/lib/utils";

const props = defineProps<{ class?: string }>();
</script>

<template>
  <CollapsibleContent
    data-slot="collapsible-content"
    :class="
      cn(
        'overflow-hidden data-[state=open]:animate-collapsible-down data-[state=closed]:animate-collapsible-up',
        props.class,
      )
    "
  >
    <slot />
  </CollapsibleContent>
</template>

On this page