Naye tools shamil kiye gaye! Dekhein kya naya hai

Home/Components/Accordion

Accordion examples

Native details aur summary elements se bani hui aik collapsible list, jis mein kisi JavaScript ki zaroorat nahi parti.

Native details aur summary elements se bani hui aik collapsible list. Expand aur collapse hona, keyboard support, aur sahi semantics sab browser khud handle karta hai, is liye is component mein bilkul bhi JavaScript shamil nahi hai.

Chevron group-open variant ka use karke rotate hota hai, iska matlab hai ke open state CSS mein style ki gayi hai na ke state mein track ki gayi hai.

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?

Accordion aik vertical list hai jismein har row ki aik heading hoti hai jis par click karke aap uska content dekh sakte hain. Yeh aik density tool hai: yeh aik page par teen paragraphs ki jagah mein bees headings dikhane ki ijazat deta hai, aur readers ko sirf wohi kholne deta hai jo unke kaam ki hon. FAQ sections sabse aam istemal hain, lekin yehhi pattern settings panels, filter groups, aur aisi har list ke liye behtar hai jahan zyada tar readers zyada tar content ko band rakhna chahte hain.

Is pattern ko baar baar JavaScript mein banaya jata hai, jiski almost kabhi zaroorat nahi hoti. HTML mein details aur summary elements hote hain jo bilkul yehhi kaam karte hain: summary clickable heading hoti hai, details ke andar baqi sab kuch panel hota hai, aur browser toggling, keyboard activation, accessibility tree mein expanded state, aur browser ki find-in-page capability ko handle karta hai jo match dikhane ke liye band section ko khol sakta hai. Aik JavaScript accordion ko yeh sab kuch dobara implement karna parta hai, aur aam tor par yeh iska zyada tar hissa ghalat tarike se karta hai.

Aik cheez jo details default tor par nahi karta woh yeh hai ke aik khulne par apne baqi siblings ko band nahi karta. Yeh behaviour - jise aksar exclusive accordion kaha jata hai - ab har details element ko wahi name attribute de kar hasil kiya ja sakta hai, jise browsers aik group ke tor par treat karte hain. Aapko iski zaroorat hai ya nahi yeh technical se zyada aik design ka sawal hai: exclusive accordions page ko chhota rakhte hain lekin do rows ko apas mein compare karna namumkin bana dete hain jab tak ke unmein se aik ko dobara na khola jaye.

Details ko style karna pehle mushkil hota tha kyunki default disclosure triangle hota hai, jo summary par aik list marker hota hai. Use hatane ke liye Tailwind mein marker:content-none ki zaroorat parti hai, sath hi purane Safari ke liye webkit-specific variant ki. Ek baar yeh hat jaye, toh summary aik aam flex container ban jata hai aur custom chevron ko apni marzi ki jagah par rakha ja sakta hai.

Anatomy

Container
Woh wrapper jo rows ko hold karta hai, jismein dividers aur max width hoti hai. Readability ke liye width ko constrain karein - full-width FAQ answers ko parhna mushkil hota hai.
Details
Har row ke liye aik. Yahan group class woh cheez hai jo chevron ko group-open variant ke zariye open state par respond karne ki ijazat deti hai.
Summary
Clickable heading. Yeh pehle se focusable aur keyboard-activatable hai, is liye isay kisi role, tabindex, ya key handler ki zaroorat nahi hai.
Indicator
Chevron, jo group-open ke sath rotate hota hai. Isay aria-hidden mark kiya gaya hai kyunki expanded state pehle hi element khud announce kar deta hai.
Panel
Details ke andar summary ke baad ka sab kuch. Yahan koi bhi markup chal sakta hai - paragraphs, lists, forms, doosray components.

How to Use

  1. 1

    Markup copy karein

    Koi bhi version le lein. React wala version aik saada function component hai jismein koi state aur koi use client directive nahi hai, is liye yeh Next.js App Router mein server component ke tor par kaam karta hai.

  2. 2

    Rows ko replace karein

    Items array ko edit karein, ya HTML version mein details block ko duplicate karein. Panels mein koi bhi markup aa sakta hai, sirf paragraph nahi.

  3. 3

    Tay karein ke kya cheez khuli hui start ho

    Jis row ko load hone par expand karna ho usmein open attribute add kar dein. Pehli wali ko kholne se yeh wazeh ho jata hai ke rows interactive hain.

  4. 4

    Choose karein ke exclusive chahiye ya nahi

    Agar aik kholne se doosri band hojani chahiye toh har details ko same name attribute dein. Agar readers rows ko compare karna chahte hon toh attribute na dein.

  5. 5

    Summary ko style karein

    Default marker ko marker:content-none ke sath remove karein, phir summary ko label aur indicator ke liye aik normal flex container ke tor par treat karein.

Features

Koi JavaScript nahi

Toggling, keyboard activation, aur state browser handle karta hai, is liye component hydration se pehle bhi kaam karta hai aur agar scripts fail ho jayein tab bhi kaam karta rehta hai.

By default correct semantics

Expanded state assistive technology ko automatically expose ho jati hai, is mein koi aria-expanded set ya sync mein rakhne ki zarurat nahi parti.

Collapsed hone par bhi findable

Browser ka find-in-page collapsed panel ko khol kar match dikha sakta hai, jo divs se bana JavaScript accordion nahi kar sakta.

CSS-driven indicator

Chevron ka rotation group-open variant se ata hai, is liye open state styling ko directly drive karti hai bajaye kisi state variable ke.

Bina code ke exclusive mode

Ek shared name attribute group ko ek waqt mein ek open rehne wale accordion ki tarah behave karwata hai, jise poori tarah browser handle karta hai.

Server-component friendly

Bina kisi state aur bina kisi effects ke, React version Next.js App Router mein server par render ho jata hai bina kisi use client directive ke.

Common Uses

FAQ sections

Sabse aam istemal. Bees sawal ek screen ki headings mein aa jate hain, aur readers sirf woh do kholte hain jo unke kaam ke hote hain.

Filter groups

Product sidebar mein collapsible category, price, aur attribute groups, taake lamba filter set choti screen par bhi easily navigate ho sake.

Settings panels

Collapsed row ke peeche advanced options ko group karna settings page ko asaan banata hai bina options ko poori tarah chupaye.

Documentation details

Pooori API tables, lambe error messages, ya optional setup steps ko disclosure ke peeche chupana taake main flow readable rahe.

Accessibility

Customization

Props

PropTypeDefaultDescription
items *{ question: string; answer: string }[]-Accordion rows. Inhein taqreeban barah ya is se kam rakhein; is se zyada hon toh aik searchable list ya alag pages behtar rehte hain.
defaultOpenIndexnumber0Kaunsi row khuli hui start ho. Pehli wali ko kholne se pata chalta hai ke rows interactive hain; sab ko band rakhne se yeh aik static headings ki list lag sakti hai.

Why Use These Accordions?

Yeh woh version hai jismein kharab hone ke chances sabse kam hain. Na koi state, na dependency, na hydration, na sync rakhne ke liye ARIA, aur aisa behaviour jo JavaScript load hone se pehle bhi kaam kare aur fail hone ke baad bhi.

Yeh findable rehta hai. Collapsed details ke andar ka content browser find-in-page se abhi bhi samne aa sakta hai, jo ke asal mein bohat se readers lambe FAQ par navigate karne ke liye istemal karte hain - ek div-based accordion us content ko search se chupchaap chupa deta hai.

React version ko kisi use client directive ki zarurat nahi hoti, is liye yeh server par render hota hai. Circulation mein mojood zyada tar accordion components sirf is liye client components hain kyunki woh open state track karte hain jo browser pehle hi track kar raha hota hai.

Tips

Frequently Asked Questions

Related Components