새로운 도구가 추가되었습니다! 새로운 소식 보기

홈/컴포넌트/Accordion

Accordion examples

JavaScript 없이 native details와 summary 요소를 사용하여 구축된 접기/펼치기 리스트입니다.

native details와 summary 요소로 구축된 접기/펼치기 리스트입니다. 펼치기/접기, 키보드 지원, 올바른 시맨틱이 모두 브라우저에서 기본 제공되므로 JavaScript가 전혀 포함되지 않습니다.

Chevron은 group-open variant를 사용하여 회전하며, 이는 open 상태가 state로 추적되는 대신 CSS로 스타일링됨을 의미합니다.

Accordion with dividers

The default FAQ layout: rows separated by hairlines, with a chevron that rotates when a row opens. No JavaScript.

Preview
export default function Accordion() {
  return (
    <div className="mx-auto max-w-2xl divide-y divide-gray-200">
      <details className="group py-4" open>
        <summary className="flex cursor-pointer list-none items-center justify-between gap-4 rounded-sm font-medium text-gray-900 outline-none focus-visible:ring-2 focus-visible:ring-gray-900 focus-visible:ring-offset-2 [&::-webkit-details-marker]:hidden">
          Do I need to install anything?
          <svg className="h-5 w-5 shrink-0 text-gray-400 transition group-open:rotate-180" fill="none" stroke="currentColor" strokeWidth="1.5" viewBox="0 0 24 24" aria-hidden="true"><path strokeLinecap="round" strokeLinejoin="round" d="m19.5 8.25-7.5 7.5-7.5-7.5" /></svg>
        </summary>
        <p className="mt-3 text-sm text-gray-600">No. Every component is plain markup you copy into your project.</p>
      </details>

      <details className="group py-4">
        <summary className="flex cursor-pointer list-none items-center justify-between gap-4 rounded-sm font-medium text-gray-900 outline-none focus-visible:ring-2 focus-visible:ring-gray-900 focus-visible:ring-offset-2 [&::-webkit-details-marker]:hidden">
          Can I use these commercially?
          <svg className="h-5 w-5 shrink-0 text-gray-400 transition group-open:rotate-180" fill="none" stroke="currentColor" strokeWidth="1.5" viewBox="0 0 24 24" aria-hidden="true"><path strokeLinecap="round" strokeLinejoin="round" d="m19.5 8.25-7.5 7.5-7.5-7.5" /></svg>
        </summary>
        <p className="mt-3 text-sm text-gray-600">Yes. No attribution is required and there is no license fee.</p>
      </details>

      <details className="group py-4">
        <summary className="flex cursor-pointer list-none items-center justify-between gap-4 rounded-sm font-medium text-gray-900 outline-none focus-visible:ring-2 focus-visible:ring-gray-900 focus-visible:ring-offset-2 [&::-webkit-details-marker]:hidden">
          Do the components work without JavaScript?
          <svg className="h-5 w-5 shrink-0 text-gray-400 transition group-open:rotate-180" fill="none" stroke="currentColor" strokeWidth="1.5" viewBox="0 0 24 24" aria-hidden="true"><path strokeLinecap="round" strokeLinejoin="round" d="m19.5 8.25-7.5 7.5-7.5-7.5" /></svg>
        </summary>
        <p className="mt-3 text-sm text-gray-600">Most do. Anything that needs state, like a menu or a dialog, uses a few lines of script.</p>
      </details>

      <details className="group py-4">
        <summary className="flex cursor-pointer list-none items-center justify-between gap-4 rounded-sm font-medium text-gray-900 outline-none focus-visible:ring-2 focus-visible:ring-gray-900 focus-visible:ring-offset-2 [&::-webkit-details-marker]:hidden">
          Which frameworks are supported?
          <svg className="h-5 w-5 shrink-0 text-gray-400 transition group-open:rotate-180" fill="none" stroke="currentColor" strokeWidth="1.5" viewBox="0 0 24 24" aria-hidden="true"><path strokeLinecap="round" strokeLinejoin="round" d="m19.5 8.25-7.5 7.5-7.5-7.5" /></svg>
        </summary>
        <p className="mt-3 text-sm text-gray-600">Every component comes as plain HTML and as a React component, both styled with Tailwind CSS.</p>
      </details>
    </div>
  );
}

Single-open accordion

Every details element shares one name attribute, so opening a row closes the others. The browser handles it, with no script.

Preview
export default function ExclusiveAccordion() {
  return (
    <div className="mx-auto max-w-2xl divide-y divide-gray-200">
      <details className="group py-4" name="faq" open>
        <summary className="flex cursor-pointer list-none items-center justify-between gap-4 rounded-sm font-medium text-gray-900 outline-none focus-visible:ring-2 focus-visible:ring-gray-900 focus-visible:ring-offset-2 [&::-webkit-details-marker]:hidden">
          Do I need to install anything?
          <svg className="h-5 w-5 shrink-0 text-gray-400 transition group-open:rotate-180" fill="none" stroke="currentColor" strokeWidth="1.5" viewBox="0 0 24 24" aria-hidden="true"><path strokeLinecap="round" strokeLinejoin="round" d="m19.5 8.25-7.5 7.5-7.5-7.5" /></svg>
        </summary>
        <p className="mt-3 text-sm text-gray-600">No. Every component is plain markup you copy into your project.</p>
      </details>

      <details className="group py-4" name="faq">
        <summary className="flex cursor-pointer list-none items-center justify-between gap-4 rounded-sm font-medium text-gray-900 outline-none focus-visible:ring-2 focus-visible:ring-gray-900 focus-visible:ring-offset-2 [&::-webkit-details-marker]:hidden">
          Can I use these commercially?
          <svg className="h-5 w-5 shrink-0 text-gray-400 transition group-open:rotate-180" fill="none" stroke="currentColor" strokeWidth="1.5" viewBox="0 0 24 24" aria-hidden="true"><path strokeLinecap="round" strokeLinejoin="round" d="m19.5 8.25-7.5 7.5-7.5-7.5" /></svg>
        </summary>
        <p className="mt-3 text-sm text-gray-600">Yes. No attribution is required and there is no license fee.</p>
      </details>

      <details className="group py-4" name="faq">
        <summary className="flex cursor-pointer list-none items-center justify-between gap-4 rounded-sm font-medium text-gray-900 outline-none focus-visible:ring-2 focus-visible:ring-gray-900 focus-visible:ring-offset-2 [&::-webkit-details-marker]:hidden">
          Do the components work without JavaScript?
          <svg className="h-5 w-5 shrink-0 text-gray-400 transition group-open:rotate-180" fill="none" stroke="currentColor" strokeWidth="1.5" viewBox="0 0 24 24" aria-hidden="true"><path strokeLinecap="round" strokeLinejoin="round" d="m19.5 8.25-7.5 7.5-7.5-7.5" /></svg>
        </summary>
        <p className="mt-3 text-sm text-gray-600">Most do. Anything that needs state, like a menu or a dialog, uses a few lines of script.</p>
      </details>

      <details className="group py-4" name="faq">
        <summary className="flex cursor-pointer list-none items-center justify-between gap-4 rounded-sm font-medium text-gray-900 outline-none focus-visible:ring-2 focus-visible:ring-gray-900 focus-visible:ring-offset-2 [&::-webkit-details-marker]:hidden">
          Which frameworks are supported?
          <svg className="h-5 w-5 shrink-0 text-gray-400 transition group-open:rotate-180" fill="none" stroke="currentColor" strokeWidth="1.5" viewBox="0 0 24 24" aria-hidden="true"><path strokeLinecap="round" strokeLinejoin="round" d="m19.5 8.25-7.5 7.5-7.5-7.5" /></svg>
        </summary>
        <p className="mt-3 text-sm text-gray-600">Every component comes as plain HTML and as a React component, both styled with Tailwind CSS.</p>
      </details>
    </div>
  );
}

Accordion with bordered cards

Each row is its own rounded card that tints when open. Reads better when the questions are unrelated rather than one continuous list.

Preview
export default function CardAccordion() {
  return (
    <div className="mx-auto max-w-2xl space-y-3">
      <details className="group rounded-lg border border-gray-200 px-4 py-3 open:bg-gray-50" open>
        <summary className="flex cursor-pointer list-none items-center justify-between gap-4 rounded-sm font-medium text-gray-900 outline-none focus-visible:ring-2 focus-visible:ring-gray-900 focus-visible:ring-offset-2 [&::-webkit-details-marker]:hidden">
          Do I need to install anything?
          <svg className="h-5 w-5 shrink-0 text-gray-400 transition group-open:rotate-180" fill="none" stroke="currentColor" strokeWidth="1.5" viewBox="0 0 24 24" aria-hidden="true"><path strokeLinecap="round" strokeLinejoin="round" d="m19.5 8.25-7.5 7.5-7.5-7.5" /></svg>
        </summary>
        <p className="mt-3 text-sm text-gray-600">No. Every component is plain markup you copy into your project.</p>
      </details>

      <details className="group rounded-lg border border-gray-200 px-4 py-3 open:bg-gray-50">
        <summary className="flex cursor-pointer list-none items-center justify-between gap-4 rounded-sm font-medium text-gray-900 outline-none focus-visible:ring-2 focus-visible:ring-gray-900 focus-visible:ring-offset-2 [&::-webkit-details-marker]:hidden">
          Can I use these commercially?
          <svg className="h-5 w-5 shrink-0 text-gray-400 transition group-open:rotate-180" fill="none" stroke="currentColor" strokeWidth="1.5" viewBox="0 0 24 24" aria-hidden="true"><path strokeLinecap="round" strokeLinejoin="round" d="m19.5 8.25-7.5 7.5-7.5-7.5" /></svg>
        </summary>
        <p className="mt-3 text-sm text-gray-600">Yes. No attribution is required and there is no license fee.</p>
      </details>

      <details className="group rounded-lg border border-gray-200 px-4 py-3 open:bg-gray-50">
        <summary className="flex cursor-pointer list-none items-center justify-between gap-4 rounded-sm font-medium text-gray-900 outline-none focus-visible:ring-2 focus-visible:ring-gray-900 focus-visible:ring-offset-2 [&::-webkit-details-marker]:hidden">
          Do the components work without JavaScript?
          <svg className="h-5 w-5 shrink-0 text-gray-400 transition group-open:rotate-180" fill="none" stroke="currentColor" strokeWidth="1.5" viewBox="0 0 24 24" aria-hidden="true"><path strokeLinecap="round" strokeLinejoin="round" d="m19.5 8.25-7.5 7.5-7.5-7.5" /></svg>
        </summary>
        <p className="mt-3 text-sm text-gray-600">Most do. Anything that needs state, like a menu or a dialog, uses a few lines of script.</p>
      </details>

      <details className="group rounded-lg border border-gray-200 px-4 py-3 open:bg-gray-50">
        <summary className="flex cursor-pointer list-none items-center justify-between gap-4 rounded-sm font-medium text-gray-900 outline-none focus-visible:ring-2 focus-visible:ring-gray-900 focus-visible:ring-offset-2 [&::-webkit-details-marker]:hidden">
          Which frameworks are supported?
          <svg className="h-5 w-5 shrink-0 text-gray-400 transition group-open:rotate-180" fill="none" stroke="currentColor" strokeWidth="1.5" viewBox="0 0 24 24" aria-hidden="true"><path strokeLinecap="round" strokeLinejoin="round" d="m19.5 8.25-7.5 7.5-7.5-7.5" /></svg>
        </summary>
        <p className="mt-3 text-sm text-gray-600">Every component comes as plain HTML and as a React component, both styled with Tailwind CSS.</p>
      </details>
    </div>
  );
}

Accordion with plus and minus icons

A plus that becomes a minus using group-open. Clearer than a chevron when the open state needs to be obvious from a distance.

Preview
export default function PlusMinusAccordion() {
  return (
    <div className="mx-auto max-w-2xl divide-y divide-gray-200">
      <details className="group py-4" open>
        <summary className="flex cursor-pointer list-none items-center justify-between gap-4 rounded-sm font-medium text-gray-900 outline-none focus-visible:ring-2 focus-visible:ring-gray-900 focus-visible:ring-offset-2 [&::-webkit-details-marker]:hidden">
          Do I need to install anything?
          <svg className="h-5 w-5 shrink-0 text-gray-400 group-open:hidden" fill="none" stroke="currentColor" strokeWidth="1.5" viewBox="0 0 24 24" aria-hidden="true"><path strokeLinecap="round" strokeLinejoin="round" d="M12 4.5v15m7.5-7.5h-15" /></svg>
          <svg className="hidden h-5 w-5 shrink-0 text-gray-400 group-open:block" fill="none" stroke="currentColor" strokeWidth="1.5" viewBox="0 0 24 24" aria-hidden="true"><path strokeLinecap="round" strokeLinejoin="round" d="M19.5 12h-15" /></svg>
        </summary>
        <p className="mt-3 text-sm text-gray-600">No. Every component is plain markup you copy into your project.</p>
      </details>

      <details className="group py-4">
        <summary className="flex cursor-pointer list-none items-center justify-between gap-4 rounded-sm font-medium text-gray-900 outline-none focus-visible:ring-2 focus-visible:ring-gray-900 focus-visible:ring-offset-2 [&::-webkit-details-marker]:hidden">
          Can I use these commercially?
          <svg className="h-5 w-5 shrink-0 text-gray-400 group-open:hidden" fill="none" stroke="currentColor" strokeWidth="1.5" viewBox="0 0 24 24" aria-hidden="true"><path strokeLinecap="round" strokeLinejoin="round" d="M12 4.5v15m7.5-7.5h-15" /></svg>
          <svg className="hidden h-5 w-5 shrink-0 text-gray-400 group-open:block" fill="none" stroke="currentColor" strokeWidth="1.5" viewBox="0 0 24 24" aria-hidden="true"><path strokeLinecap="round" strokeLinejoin="round" d="M19.5 12h-15" /></svg>
        </summary>
        <p className="mt-3 text-sm text-gray-600">Yes. No attribution is required and there is no license fee.</p>
      </details>

      <details className="group py-4">
        <summary className="flex cursor-pointer list-none items-center justify-between gap-4 rounded-sm font-medium text-gray-900 outline-none focus-visible:ring-2 focus-visible:ring-gray-900 focus-visible:ring-offset-2 [&::-webkit-details-marker]:hidden">
          Do the components work without JavaScript?
          <svg className="h-5 w-5 shrink-0 text-gray-400 group-open:hidden" fill="none" stroke="currentColor" strokeWidth="1.5" viewBox="0 0 24 24" aria-hidden="true"><path strokeLinecap="round" strokeLinejoin="round" d="M12 4.5v15m7.5-7.5h-15" /></svg>
          <svg className="hidden h-5 w-5 shrink-0 text-gray-400 group-open:block" fill="none" stroke="currentColor" strokeWidth="1.5" viewBox="0 0 24 24" aria-hidden="true"><path strokeLinecap="round" strokeLinejoin="round" d="M19.5 12h-15" /></svg>
        </summary>
        <p className="mt-3 text-sm text-gray-600">Most do. Anything that needs state, like a menu or a dialog, uses a few lines of script.</p>
      </details>

      <details className="group py-4">
        <summary className="flex cursor-pointer list-none items-center justify-between gap-4 rounded-sm font-medium text-gray-900 outline-none focus-visible:ring-2 focus-visible:ring-gray-900 focus-visible:ring-offset-2 [&::-webkit-details-marker]:hidden">
          Which frameworks are supported?
          <svg className="h-5 w-5 shrink-0 text-gray-400 group-open:hidden" fill="none" stroke="currentColor" strokeWidth="1.5" viewBox="0 0 24 24" aria-hidden="true"><path strokeLinecap="round" strokeLinejoin="round" d="M12 4.5v15m7.5-7.5h-15" /></svg>
          <svg className="hidden h-5 w-5 shrink-0 text-gray-400 group-open:block" fill="none" stroke="currentColor" strokeWidth="1.5" viewBox="0 0 24 24" aria-hidden="true"><path strokeLinecap="round" strokeLinejoin="round" d="M19.5 12h-15" /></svg>
        </summary>
        <p className="mt-3 text-sm text-gray-600">Every component comes as plain HTML and as a React component, both styled with Tailwind CSS.</p>
      </details>
    </div>
  );
}

FAQ section with heading beside the accordion

A heading and support line on the left and the accordion on the right at lg, stacked on smaller screens. Suits a full FAQ section on a landing page.

Preview
export default function FaqSection() {
  return (
    <section className="mx-auto grid max-w-5xl gap-10 px-4 py-12 lg:grid-cols-3">
      <div className="bg-gray-900 p-4 rounded-lg">
        <h2 className="text-2xl font-bold text-gray-100">Frequently asked questions</h2>
        <p className="mt-3 text-sm text-white">Cannot find an answer? Email us and we will reply within a day.</p>
      </div>

      <div className="divide-y divide-gray-200 lg:col-span-2">
        <details className="group py-4" open>
          <summary className="flex cursor-pointer list-none items-center justify-between gap-4 rounded-sm font-medium text-gray-900 outline-none focus-visible:ring-2 focus-visible:ring-gray-900 focus-visible:ring-offset-2 [&::-webkit-details-marker]:hidden">
            Do I need to install anything?
            <svg className="h-5 w-5 shrink-0 text-gray-400 transition group-open:rotate-180" fill="none" stroke="currentColor" strokeWidth="1.5" viewBox="0 0 24 24" aria-hidden="true"><path strokeLinecap="round" strokeLinejoin="round" d="m19.5 8.25-7.5 7.5-7.5-7.5" /></svg>
          </summary>
          <p className="mt-3 text-sm text-gray-600">No. Every component is plain markup you copy into your project.</p>
        </details>

        <details className="group py-4">
          <summary className="flex cursor-pointer list-none items-center justify-between gap-4 rounded-sm font-medium text-gray-900 outline-none focus-visible:ring-2 focus-visible:ring-gray-900 focus-visible:ring-offset-2 [&::-webkit-details-marker]:hidden">
            Can I use these commercially?
            <svg className="h-5 w-5 shrink-0 text-gray-400 transition group-open:rotate-180" fill="none" stroke="currentColor" strokeWidth="1.5" viewBox="0 0 24 24" aria-hidden="true"><path strokeLinecap="round" strokeLinejoin="round" d="m19.5 8.25-7.5 7.5-7.5-7.5" /></svg>
          </summary>
          <p className="mt-3 text-sm text-gray-600">Yes. No attribution is required and there is no license fee.</p>
        </details>

        <details className="group py-4">
          <summary className="flex cursor-pointer list-none items-center justify-between gap-4 rounded-sm font-medium text-gray-900 outline-none focus-visible:ring-2 focus-visible:ring-gray-900 focus-visible:ring-offset-2 [&::-webkit-details-marker]:hidden">
            Do the components work without JavaScript?
            <svg className="h-5 w-5 shrink-0 text-gray-400 transition group-open:rotate-180" fill="none" stroke="currentColor" strokeWidth="1.5" viewBox="0 0 24 24" aria-hidden="true"><path strokeLinecap="round" strokeLinejoin="round" d="m19.5 8.25-7.5 7.5-7.5-7.5" /></svg>
          </summary>
          <p className="mt-3 text-sm text-gray-600">Most do. Anything that needs state, like a menu or a dialog, uses a few lines of script.</p>
        </details>

        <details className="group py-4">
          <summary className="flex cursor-pointer list-none items-center justify-between gap-4 rounded-sm font-medium text-gray-900 outline-none focus-visible:ring-2 focus-visible:ring-gray-900 focus-visible:ring-offset-2 [&::-webkit-details-marker]:hidden">
            Which frameworks are supported?
            <svg className="h-5 w-5 shrink-0 text-gray-400 transition group-open:rotate-180" fill="none" stroke="currentColor" strokeWidth="1.5" viewBox="0 0 24 24" aria-hidden="true"><path strokeLinecap="round" strokeLinejoin="round" d="m19.5 8.25-7.5 7.5-7.5-7.5" /></svg>
          </summary>
          <p className="mt-3 text-sm text-gray-600">Every component comes as plain HTML and as a React component, both styled with Tailwind CSS.</p>
        </details>
      </div>
    </section>
  );
}

What is a Accordion?

아코디언은 각 행에 클릭하여 콘텐츠를 볼 수 있는 헤딩이 있는 수직 리스트입니다. 공간 절약 도구로, 세 문단의 공간에 스무 개의 헤딩을 표시할 수 있게 해주며 독자가 자신에게 해당하는 내용만 열어볼 수 있도록 합니다. FAQ 섹션이 가장 흔한 용도이지만, 설정 패널, 필터 그룹, 그리고 대부분의 독자가 대부분의 내용을 접어두기를 원하는 모든 리스트에 동일한 패턴이 유용합니다.

이 패턴은 JavaScript로 끊임없이 다시 구현되지만, 거의 항상 불필요합니다. HTML에는 이를 정확히 수행하는 details와 summary 요소가 있습니다. summary는 클릭 가능한 헤딩이고, details 내부의 다른 모든 것은 패널이며, 브라우저가 토글, 키보드 활성화, 접근성 트리의 expanded 상태, 그리고 브라우저 내 페이지 찾기(find-in-page)가 검색 결과 매칭을 보여주기 위해 접힌 섹션을 여는 기능까지 처리합니다. JavaScript 아코디언은 그 모든 것을 다시 구현해야 하며, 일반적으로 대부분을 잘못 구현합니다.

details가 기본적으로 하지 않는 한 가지는 하나가 열릴 때 형제 요소를 닫는 것입니다. 흔히 exclusive 아코디언이라고 부르는 이 동작은 이제 모든 details 요소에 브라우저가 그룹으로 취급하는 동일한 name 속성을 부여하여 사용할 수 있습니다. 이를 사용할지 여부는 기술적인 문제라기보다는 실제 디자인 질문입니다. exclusive 아코디언은 페이지를 짧게 유지하지만, 행 중 하나를 다시 열지 않고는 두 행을 비교하는 것을 불가능하게 만듭니다.

details 스타일링은 summary의 리스트 마커인 기본 disclosure 삼각형 때문에 예전에는 까다로웠습니다. 이를 제거하려면 Tailwind의 marker:content-none과 구형 Safari를 위한 webkit 전용 variant가 필요합니다. 제거하고 나면 summary는 일반적인 flex 컨테이너가 되며 커스텀 chevron을 제자리에 배치할 수 있습니다.

Anatomy

Container
구분선과 최대 너비를 포함하는 행 래퍼입니다. 가독성을 위해 너비를 제한하세요. 전체 너비 FAQ 답변은 훑어보기 어렵습니다.
Details
행당 하나씩 들어갑니다. 여기서 group 클래스는 chevron이 group-open variant를 통해 open 상태에 반응할 수 있도록 해줍니다.
Summary
클릭 가능한 헤딩입니다. 이미 포커스 가능하고 키보드로 활성화할 수 있으므로 role, tabindex, 키 핸들러가 필요 없습니다.
Indicator
group-open으로 회전되는 chevron입니다. expanded 상태가 요소 자체에 의해 이미 안내되므로 aria-hidden으로 표시됩니다.
Panel
summary 뒤에 오는 details 내부의 모든 것입니다. 문단, 리스트, 폼, 기타 컴포넌트 등 어떤 마크업이든 작동합니다.

How to Use

  1. 1

    마크업 복사하기

    두 버전 중 하나를 선택하세요. React 버전은 state와 use client 지시문이 없는 순수 함수형 컴포넌트이므로 Next.js App Router에서 서버 컴포넌트로 작동합니다.

  2. 2

    행 교체하기

    items 배열을 수정하거나 HTML 버전에서 details 블록을 복제하세요. 패널은 문단뿐만 아니라 모든 마크업을 허용합니다.

  3. 3

    열린 상태로 시작할 항목 결정하기

    로드 시 펼쳐져야 하는 행에 open 속성을 추가하세요. 첫 번째 행을 열어두면 행이 인터랙티브하다는 것이 명확해집니다.

  4. 4

    exclusive 여부 선택하기

    하나를 열었을 때 다른 것들이 닫히게 하려면 모든 details에 동일한 name 속성을 부여하세요. 독자가 행들을 비교해야 할 수 있다면 속성을 생략하세요.

  5. 5

    summary 스타일링하기

    marker:content-none으로 기본 마커를 제거한 다음, summary를 레이블과 indicator를 위한 일반 flex 컨테이너로 다루세요.

Features

JavaScript 없음

토글, 키보드 활성화 및 상태는 브라우저에서 처리하므로, 컴포넌트는 하이드레이션 전에도 작동하며 스크립트가 실패하더라도 계속 작동합니다.

기본적으로 올바른 시맨틱스

확장된 상태는 aria-expanded를 설정하거나 동기화할 필요 없이 보조 기술에 자동으로 노출됩니다.

접힌 상태에서도 검색 가능

브라우저의 페이지 내 찾기 기능을 통해 접힌 패널을 열어 일치하는 항목을 찾을 수 있습니다. 이는 div로 구축된 자바스크립트 아코디언으로는 불가능한 기능입니다.

CSS 기반 인디케이터

chevron 회전은 group-open variant에서 오므로, 상태 변수를 통하는 대신 열림 상태가 스타일링을 직접 제어합니다.

코드 없는 익스클루시브 모드

공유되는 name 속성 덕분에 브라우저가 완전히 처리하여 그룹이 한 번에 하나만 열리는 아코디언처럼 작동합니다.

서버 컴포넌트 친화적

상태와 effect가 없으므로, React 버전은 use client 디렉티브 없이 Next.js 앱Router에서 서버에 렌더링됩니다.

Common Uses

FAQ 섹션

가장 흔한 사용 사례입니다. 스크럼 한 화면에 20개의 질문 제목이 들어가고, 독자는 자신에게 해당하는 두 개만 엽니다.

필터 그룹

제품 사이드바의 접을 수 있는 카테고리, 가격, 속성 그룹으로, 긴 필터 세트가 짧은 화면에서도 탐색 가능하게 유지됩니다.

설정 패널

접힌 행 뒤에 고급 옵션을 그룹화하면 옵션을 완전히 숨기지 않으면서도 설정 페이지를 다루기 쉽게 유지할 수 있습니다.

문서 세부 정보

전체 API 테이블, 긴 오류 메시지 또는 선택적 설정 단계를 disclosure 뒤로 숨겨 메인 플로우를 읽기 쉽게 유지합니다.

Accessibility

Customization

Props

PropTypeDefaultDescription
items *{ question: string; answer: string }[]-아코디언 행입니다. 12개 이하로 유지하는 것이 좋으며, 그 이상일 경우 검색 가능한 리스트나 별도의 페이지 세트를 사용하는 것이 독자에게 더 좋습니다.
defaultOpenIndexnumber0어떤 행이 펼쳐진 상태로 시작할지 결정합니다. 첫 번째 행을 열어두면 행들이 인터랙티브하다는 신호를 주며, 모두 닫혀 있으면 정적 헤딩 리스트로 오인될 수 있습니다.

Why Use These Accordions?

오류가 발생할 여지가 가장 적은 버전입니다. 상태, 의존성, 하이드레이션, 동기화할 ARIA가 없으며, JavaScript가 로드되기 전과 실패한 후에도 작동하는 동작을 제공합니다.

찾기 기능이 유지됩니다. 접힌 details 안의 콘텐츠는 브라우저의 페이지 내 찾기 기능으로 여전히 표면화될 수 있습니다. 이는 많은 독자가 긴 FAQ를 탐색하는 실제 방식이며, div 기반 아코디언은 해당 콘텐츠를 검색에서 조용히 숨깁니다.

React 버전은 use client 디렉티브가 필요 없으므로 서버에서 렌더링됩니다. 유통되는 대부분의 아코디언 컴포넌트가 순수하게 클라이언트 컴포넌트인 이유는 브라우저가 이미 추적하고 있던 열림 상태를 추적하기 때문입니다.

Tips

Frequently Asked Questions

Related Components