Accordion

Card Accordion

An accordion of separate cards: every section carries its own border, and the open one lifts on a shadow. The sections are independent — in a list of cards, closing one to open another reads as a bug.

  • accordion
  • cards
  • faq
  • no-js

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/accordion-002?lang=en

Как устроена оплата?

Помесячно или за год. Год дешевле на два месяца, счёт выставляется сразу, отказаться можно в любой момент — остаток вернём пропорционально.

Данные в безопасности?

Шифрование при передаче и в хранилище, ежедневные резервные копии за последние 30 дней, доступ по ролям. Ключи хранятся отдельно от данных.

Какие интеграции поддерживаются?

Готовые связки с почтой, платежами и аналитикой. Всё остальное — через веб-хуки и открытый API, ключи выдаются в настройках проекта.

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 "accordion-002" (Card Accordion) 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/accordion-002.json

Registry item: https://vibeui.ru/r/accordion-002.json
Installs to: components/vibeui/accordion-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
An accordion of separate cards: every section carries its own border, and the open one lifts on a shadow. The sections are independent — in a list of cards, closing one to open another reads as a bug.

An accordion where each section is a standalone card with its own border and radius. The open card takes an accent border and a soft shadow, so it reads as a unit rather than a row in a continuous list. Opening rests on native details, with no client JS. Zero dependencies, one file, its own palette.

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

<Accordion002
  items={[{ question: "How does billing work?", answer: "Monthly or yearly." }]}
/>

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-accordion-002-* palette — do not swap it for your theme tokens (bg-card, border-border and the like)
- the native details/summary: replacing them with useState buttons gives up find-on-page, keyboard behaviour and pre-hydration state
- the independence of the sections: cards stand on their own, and closing a neighbour to open one reads as a fault
- the shadow and accent border on the open card — they are what separates it from its closed neighbours
- hiding the system marker (list-style:none and ::-webkit-details-marker) alongside the custom chevron
- the focus-visible outline on summary with its negative offset: headings are tabbed through
- the @container query instead of a media query: the cards live in a narrow column and full width alike
- the <style> block inside the component — it holds the palette, the layout and the chevron

## 6. You may change
- the items array: questions and answers
- defaultOpen — which section starts open; -1 closes them all
- the accent through the accent prop — it colours the open card's border, the chevron well and focus
- max width and outer spacing through className

## 7. Rules
- If you need one-at-a-time behaviour, use accordion-001: it links the sections through the name attribute.
- Do not animate the open height by hand: native details has no such animation, and faking it brings back the JS this component exists to avoid.
- More than seven cards in a row read worse than a flat list: break a long set up with headings.
- 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/accordion-002.json
https://vibeui.ru/r/accordion-002.json

Компонент самодостаточен: один файл, без зависимостей, собственная палитра в локальных переменных --vibeui-accordion-002-*. Раскрытие держат нативные <details>/<summary>: состояние работает до гидратации, а найденный поиском по странице раздел браузер раскрывает сам. В отличие от accordion-001 разделы независимы и не связаны атрибутом name, каждый несёт собственную рамку и тень в открытом состоянии. Значок — грани квадрата в круглой лунке; отступы и кегль считаются от собственной ширины через @container.

Component source

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

import type { ComponentPropsWithoutRef, CSSProperties } from "react"

export type Accordion002Item = {
  question: string
  answer: string
}

export type Accordion002Props = Omit<
  ComponentPropsWithoutRef<"div">,
  "children"
> & {
  items?: Accordion002Item[]
  /** Номер раздела, открытого сразу. -1 — все закрыты. */
  defaultOpen?: number
  accent?: string
}

// Идея компонента: каждый раздел — отдельная карточка с собственной рамкой,
// а не строка в общем списке. Открытый раздел приподнимается тенью, поэтому
// видно, что это самостоятельная единица, а не часть сплошного полотна.
// Разделы независимы: в списке карточек взаимное закрытие выглядит поломкой.
const STYLES = `
:where([data-vibeui-block="accordion-002"]){
--vibeui-accordion-002-fg:oklch(0.24 0.016 265);
--vibeui-accordion-002-muted:oklch(0.5 0.014 265);
--vibeui-accordion-002-bg:oklch(1 0 0);
--vibeui-accordion-002-border:oklch(0.9 0.006 265);
--vibeui-accordion-002-accent:oklch(0.55 0.2 262);
--vibeui-accordion-002-radius:0.875rem;
--vibeui-accordion-002-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
container-type:inline-size;
}
[data-vibeui-block="accordion-002"]{
display:flex;flex-direction:column;gap:0.625rem;
width:100%;max-width:44rem;box-sizing:border-box;
color:var(--vibeui-accordion-002-fg);font-family:var(--vibeui-accordion-002-font);
}
[data-vibeui-block="accordion-002"] details{
border:1px solid var(--vibeui-accordion-002-border);
border-radius:var(--vibeui-accordion-002-radius);
background:var(--vibeui-accordion-002-bg);
transition:border-color .16s ease,box-shadow .18s ease;
}
[data-vibeui-block="accordion-002"] details:hover{border-color:color-mix(in oklab,var(--vibeui-accordion-002-accent) 25%,var(--vibeui-accordion-002-border))}
/* Открытая карточка приподнята: она перестаёт быть строкой списка. */
[data-vibeui-block="accordion-002"] details[open]{
border-color:color-mix(in oklab,var(--vibeui-accordion-002-accent) 40%,var(--vibeui-accordion-002-border));
box-shadow:0 10px 26px -18px oklch(0.2 0.03 265 / 45%);
}
[data-vibeui-block="accordion-002"] summary{
display:flex;align-items:center;justify-content:space-between;gap:1rem;
padding:0.9375rem 1.125rem;cursor:pointer;list-style:none;
font-size:0.9375rem;font-weight:550;line-height:1.4;
}
[data-vibeui-block="accordion-002"] summary::-webkit-details-marker{display:none}
[data-vibeui-block="accordion-002"] summary:focus-visible{
outline:2px solid var(--vibeui-accordion-002-accent);outline-offset:-2px;
border-radius:var(--vibeui-accordion-002-radius);
}
/* Значок в круглой лунке: у карточки собственный угол, значку нужен свой. */
[data-vibeui-block="accordion-002"] [data-part="chevron"]{
display:flex;align-items:center;justify-content:center;flex:none;
width:1.5rem;height:1.5rem;border-radius:9999px;
background:color-mix(in oklab,var(--vibeui-accordion-002-border) 45%,transparent);
transition:background-color .16s ease;
}
[data-vibeui-block="accordion-002"] [data-part="chevron"]::before{
content:"";width:0.4375rem;height:0.4375rem;
border-right:1.5px solid var(--vibeui-accordion-002-muted);
border-bottom:1.5px solid var(--vibeui-accordion-002-muted);
transform:rotate(45deg) translate(-0.0625rem,-0.0625rem);
transition:transform .18s ease,border-color .16s ease;
}
[data-vibeui-block="accordion-002"] details[open] [data-part="chevron"]{background:color-mix(in oklab,var(--vibeui-accordion-002-accent) 14%,transparent)}
[data-vibeui-block="accordion-002"] details[open] [data-part="chevron"]::before{
transform:rotate(225deg) translate(-0.0625rem,-0.0625rem);
border-right-color:var(--vibeui-accordion-002-accent);
border-bottom-color:var(--vibeui-accordion-002-accent);
}
[data-vibeui-block="accordion-002"] [data-part="answer"]{
margin:0;padding:0 1.125rem 1.0625rem;
font-size:0.875rem;line-height:1.6;color:var(--vibeui-accordion-002-muted);max-width:62ch;
}
@container (min-width: 32rem){
[data-vibeui-block="accordion-002"] summary{padding:1.0625rem 1.375rem;font-size:1rem}
[data-vibeui-block="accordion-002"] [data-part="answer"]{padding:0 1.375rem 1.25rem;font-size:0.9375rem}
}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="accordion-002"] *{animation:none!important;transition:none!important}}
`

const DEFAULT_ITEMS: Accordion002Item[] = [
  {
    question: "Как устроена оплата?",
    answer:
      "Помесячно или за год. Год дешевле на два месяца, счёт выставляется сразу, отказаться можно в любой момент — остаток вернём пропорционально.",
  },
  {
    question: "Данные в безопасности?",
    answer:
      "Шифрование при передаче и в хранилище, ежедневные резервные копии за последние 30 дней, доступ по ролям. Ключи хранятся отдельно от данных.",
  },
  {
    question: "Какие интеграции поддерживаются?",
    answer:
      "Готовые связки с почтой, платежами и аналитикой. Всё остальное — через веб-хуки и открытый API, ключи выдаются в настройках проекта.",
  },
]

/**
 * Аккордеон из отдельных карточек: открытая приподнимается тенью.
 * Один файл, ноль зависимостей, собственная палитра.
 */
export function Accordion002({
  items = DEFAULT_ITEMS,
  defaultOpen = 0,
  accent,
  className,
  style,
  ...props
}: Accordion002Props) {
  const palette = {
    ...(accent ? { "--vibeui-accordion-002-accent": accent } : null),
    ...style,
  } as CSSProperties

  return (
    <>
      <style href="vibeui-accordion-002" precedence="medium">
        {STYLES}
      </style>
      <div
        {...props}
        data-vibeui-block="accordion-002"
        className={className}
        style={palette}
      >
        {items.map((item, index) => (
          <details key={item.question} open={index === defaultOpen}>
            <summary>
              {item.question}
              <span data-part="chevron" aria-hidden="true" />
            </summary>
            <p data-part="answer">{item.answer}</p>
          </details>
        ))}
      </div>
    </>
  )
}