Display

Animated Height

A disclosure with a real height animation: a grid wrapper travels from 0fr to 1fr, so the content height never has to be known upfront.

  • collapsible
  • animation
  • grid
  • disclosure

Preview

1440pxHost theme

Use it with AI

  1. 1. Copy the link.
  2. 2. Write to your agent in your own words and drop the link into the sentence.
  3. 3. The agent opens the link and installs the component from the registry.

put this in the header: https://vibeui.ru/c/collapsible-002?lang=en

Один .tsx-файл со всеми стилями внутри, без npm-зависимостей и без обращений к теме проекта. Палитра объявлена локальными переменными, поэтому компонент выглядит одинаково в любом окружении.

Show the full instructions

What the link says, spelled out. Use it when your agent cannot open links — paste this text instead.

# Install and place "collapsible-002" (Animated Height) from VibeUI

## 1. Install first — do not skip, do not recreate
Run this exact command before writing any code:
npx shadcn@latest add https://vibeui.ru/r/collapsible-002.json

Registry item: https://vibeui.ru/r/collapsible-002.json
Installs to: components/vibeui/collapsible-002.tsx (the exact path follows this project's components.json aliases).
npm dependencies: none.
Registry dependencies: none.

Install it from the registry. Do not recreate it from the description,
do not substitute a similar component from another library, and do not
rewrite it to match the project's existing style.

## 2. What it is
A disclosure with a real height animation: a grid wrapper travels from 0fr to 1fr, so the content height never has to be known upfront.

A disclosure with an honest height animation on grid-template-rows 0fr→1fr: the browser computes the final height for you. The trigger carries aria-expanded and aria-controls. Zero dependencies, one file.

## 3. How to use it
import { Collapsible002 } from "@/components/vibeui/collapsible-002"

<Collapsible002 title="What you get" defaultOpen />

Read the installed file for the full prop list.

## 4. Where to place it
This is a small inline component. Put it exactly where the user asked,
inside the existing markup. Do not create a new page, section or
wrapper for it. If a similar control already sits in that spot,
replace it instead of adding a second one.

Placement: ___
(The user fills this line in. If it is still blank, ask where to put it
instead of guessing.)

## 5. Keep exactly as installed
- the local --vibeui-collapsible-002-* palette — do not swap it for your theme tokens
- the 0fr→1fr trick: height:auto does not animate and max-height snaps at the end
- overflow:hidden and min-height:0 on the inner layer — without them the grid row will not shrink
- the inert attribute on the collapsed part: otherwise Tab moves focus into invisible content
- the aria-expanded plus aria-controls pairing on the trigger — that is how the state is announced
- the prefers-reduced-motion rule: height animation is the worst offender for vestibular disorders

## 6. You may change
- the heading through the title prop
- the body copy through the text prop
- the initial state through the defaultOpen prop
- the transition duration and the accent through the accent prop

## 7. Rules
- The content stays in the DOM while collapsed: mount heavy lists on demand instead.
- Put padding on the text itself, not on the overflow layer, or it will not collapse with the height.
- Animating grid-template-rows is unsupported in older browsers: there the disclosure simply snaps.
- Do not lift the CSS variables into globals.css: the component has to stay a single file.

## 8. Verify
- it renders with no console errors;
- it looks like the preview on the VibeUI page you copied this from;
- if it does not, you changed something listed in section 5 — put it back.

For developers

npx shadcn@latest add https://vibeui.ru/r/collapsible-002.json
https://vibeui.ru/r/collapsible-002.json

Компонент самодостаточен: один файл, без зависимостей, собственная палитра в локальных переменных --vibeui-collapsible-002-*. Клиентский: "use client" ради useState и aria-expanded. Анимация высоты сделана гридом: обёртка [data-part="wrap"] переключает grid-template-rows с 0fr на 1fr, внутренний слой держит overflow:hidden и min-height:0 — без него строка грида не сжимается ниже содержимого. Скрытая часть помечена атрибутом inert, поэтому в свёрнутом виде её содержимое выпадает из табуляции.

Component source

The same file your agent installs. Here in case you would rather copy it by hand.

"use client"

import { useId, useState } from "react"
import type { ComponentPropsWithoutRef, CSSProperties } from "react"

export type Collapsible002Props = Omit<
  ComponentPropsWithoutRef<"section">,
  "children" | "title"
> & {
  title?: string
  text?: string
  defaultOpen?: boolean
  accent?: string
}

// Идея компонента: свёртка с честной анимацией высоты. Высота содержимого
// заранее неизвестна, а height:auto не анимируется, поэтому обёртка — грид с
// grid-template-rows от 0fr к 1fr: браузер сам считает конечную высоту и
// плавно к ней едет. Внутренний слой держит overflow:hidden и min-height:0,
// иначе строка грида не сожмётся ниже содержимого.
const STYLES = `
:where([data-vibeui-block="collapsible-002"]){
--vibeui-collapsible-002-bg:oklch(1 0 0);
--vibeui-collapsible-002-fg:oklch(0.24 0.014 265);
--vibeui-collapsible-002-muted:oklch(0.56 0.014 265);
--vibeui-collapsible-002-border:oklch(0.9 0.006 265);
--vibeui-collapsible-002-accent:oklch(0.58 0.16 200);
--vibeui-collapsible-002-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
[data-vibeui-block="collapsible-002"]{
display:block;box-sizing:border-box;width:100%;max-width:24rem;
background:var(--vibeui-collapsible-002-bg);color:var(--vibeui-collapsible-002-fg);
border:1px solid var(--vibeui-collapsible-002-border);border-radius:0.875rem;
font-family:var(--vibeui-collapsible-002-font);
}
[data-vibeui-block="collapsible-002"] [data-part="trigger"]{
display:flex;align-items:center;gap:0.625rem;
box-sizing:border-box;width:100%;padding:0.8125rem 0.875rem;
appearance:none;border:0;background:none;cursor:pointer;text-align:left;
color:inherit;font:inherit;font-size:0.875rem;font-weight:650;
border-radius:0.875rem;
}
[data-vibeui-block="collapsible-002"] [data-part="trigger"]:focus-visible{outline:2px solid var(--vibeui-collapsible-002-accent);outline-offset:-2px}
[data-vibeui-block="collapsible-002"] [data-part="mark"]{
flex:none;margin-left:auto;position:relative;width:0.75rem;height:0.75rem;
}
[data-vibeui-block="collapsible-002"] [data-part="mark"]::before,
[data-vibeui-block="collapsible-002"] [data-part="mark"]::after{
content:"";position:absolute;inset:50% 0 auto;
height:2px;border-radius:2px;background:var(--vibeui-collapsible-002-accent);
transform:translateY(-50%);transition:transform .24s ease,opacity .24s ease;
}
/* Плюс превращается в минус: вторая палка просто ложится и гаснет. */
[data-vibeui-block="collapsible-002"] [data-part="mark"]::after{transform:translateY(-50%) rotate(90deg)}
[data-vibeui-block="collapsible-002"] [data-part="trigger"][aria-expanded="true"] [data-part="mark"]::after{transform:translateY(-50%) rotate(0deg);opacity:0}
/* 0fr → 1fr: единственный способ анимировать высоту неизвестного содержимого. */
[data-vibeui-block="collapsible-002"] [data-part="wrap"]{
display:grid;grid-template-rows:0fr;
transition:grid-template-rows .28s cubic-bezier(.32,.72,0,1);
}
[data-vibeui-block="collapsible-002"] [data-part="wrap"][data-open="true"]{grid-template-rows:1fr}
[data-vibeui-block="collapsible-002"] [data-part="inner"]{overflow:hidden;min-height:0}
[data-vibeui-block="collapsible-002"] [data-part="body"]{
margin:0;padding:0 0.875rem 0.875rem;
font-size:0.8125rem;line-height:1.55;color:var(--vibeui-collapsible-002-muted);
}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="collapsible-002"] *{animation:none!important;transition:none!important}}
`

/**
 * Свёртка с плавной анимацией высоты на grid-template-rows 0fr→1fr.
 * Один файл, ноль зависимостей, собственная палитра.
 */
export function Collapsible002({
  title = "Что входит в поставку",
  text = "Один .tsx-файл со всеми стилями внутри, без npm-зависимостей и без обращений к теме проекта. Палитра объявлена локальными переменными, поэтому компонент выглядит одинаково в любом окружении.",
  defaultOpen = true,
  accent,
  className,
  style,
  ...props
}: Collapsible002Props) {
  const [open, setOpen] = useState(defaultOpen)
  const bodyId = useId()

  const palette = {
    ...(accent ? { "--vibeui-collapsible-002-accent": accent } : null),
    ...style,
  } as CSSProperties

  return (
    <>
      <style href="vibeui-collapsible-002" precedence="medium">
        {STYLES}
      </style>
      <section
        {...props}
        data-vibeui-block="collapsible-002"
        className={className}
        style={palette}
      >
        <button
          type="button"
          data-part="trigger"
          aria-expanded={open}
          aria-controls={bodyId}
          onClick={() => setOpen((value) => !value)}
        >
          {title}
          <span data-part="mark" aria-hidden="true" />
        </button>
        <div data-part="wrap" data-open={open}>
          <div id={bodyId} data-part="inner" inert={!open}>
            <p data-part="body">{text}</p>
          </div>
        </div>
      </section>
    </>
  )
}