Yeni araçlar eklendi! Yenilikleri keşfet

Ana Sayfa/Bileşenler/Akordeon

Akordeon examples

JavaScript gerektirmeyen, yerel details ve summary elementleriyle oluşturulmuş açılır kapanır liste.

Yerel details ve summary elementleriyle oluşturulmuş açılır kapanır liste. Genişletme ve daraltma, klavye desteği ve doğru semantiklerin tümü tarayıcıdan gelir, bu nedenle bileşen hiç JavaScript içermez.

Ok simgesi group-open varyantı kullanılarak döner; bu, açık durumun state içinde takip edilmek yerine CSS ile şekillendirildiği anlamına gelir.

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 Akordeon?

Akordeon, her satırda içeriğini ortaya çıkarmak için tıklayabileceğiniz bir başlığın bulunduğu dikey bir listedir. Bu bir yoğunluk aracıdır: bir sayfanın yirmi başlığı üç paragrafın kapladığı alanda göstermesini sağlar ve okuyucuların yalnızca kendilerini ilgilendirenleri açmasına olanak tanır. SSS bölümleri en yaygın kullanım alanıdır, ancak aynı desen ayarlar panellerini, filtre gruplarını ve okuyucuların çoğunun içeriğin çoğunun kapalı olmasını istediği herhangi bir listeyi destekler.

Bu desen sürekli olarak JavaScript ile yeniden oluşturulur, ki bu neredeyse her zaman gereksizdir. HTML, tam olarak bunu yapan details ve summary elementlerine sahiptir: summary tıklanabilir başlıktır, details içindeki her şey paneldir ve tarayıcı geçişleri, klavye aktivasyonunu, erişilebilirlik ağacındaki expanded durumunu ve tarayıcının sayfada bul (find-in-page) özelliğinin eşleşmeyi göstermek için kapalı bir bölümü açabilme yeteneğini yönetir. JavaScript akordeonu tüm bunları yeniden uygulamak zorundadır ve tipik olarak çoğunu yanlış uygular.

details elementinin varsayılan olarak yapmadığı tek şey, biri açıldığında kardeşlerini kapatmamaktır. Çoğu zaman özel (exclusive) akordeon olarak adlandırılan bu davranış, artık her details elementine tarayıcıların grup olarak ele aldığı aynı name özniteliğinin verilmesiyle mümkündür. Bunu isteyip istemediğiniz teknik olmaktan ziyade gerçek bir tasarım sorusudur: özel akordeonlar sayfayı kısa tutar ancak bunlardan birini yeniden açmadan iki satırı karşılaştırmayı imkansız hale getirir.

details stilini düzenlemek, summary üzerinde bir liste işareti olan varsayılan üçgen nedeniyle eskiden zordu. Bunu kaldırmak, Tailwind'de marker:content-none ve eski Safari'de webkit'e özel varyantı gerektirir. Bu kaldırıldıktan sonra summary sıradan bir flex konteyneridir ve özel ok simgesi ait olduğu yere konumlandırılabilir.

Anatomy

Konteyner
Satırları tutan, ayırıcıları ve maksimum genişliği taşıyan sarmalayıcı. Okunabilirlik için genişliği sınırlayın - tam genişlikteki SSS yanıtlarının taranması zordur.
Details
Satır başına bir tane. Buradaki group sınıfı, ok simgesinin group-open varyantı aracılığıyla açık duruma yanıt vermesini sağlayan şeydir.
Summary
Tıklanabilir başlık. Zaten odaklanılabilir ve klavyeyle etkinleştirilebilir durumdadır, bu nedenle role, tabindex ve tuş işleyicisine ihtiyaç duymaz.
Gösterge
group-open ile döndürülen ok simgesi. Genişletilmiş durum zaten elementin kendisi tarafından duyurulduğu için aria-hidden olarak işaretlenmiştir.
Panel
summary'den sonra details içindeki her şey. Burada herhangi bir biçimlendirme çalışır - paragraflar, listeler, formlar, diğer bileşenler.

How to Use

  1. 1

    Biçimlendirmeyi kopyala

    İstediğiniz versiyonu alın. React versiyonu, state'i ve use client direktifi olmayan düz bir fonksiyon bileşenidir, bu nedenle Next.js App Router içinde bir sunucu bileşeni olarak çalışır.

  2. 2

    Satırları değiştirin

    items dizisini düzenleyin veya HTML versiyonunda bir details bloğunu kopyalayın. Paneller sadece paragraf değil, herhangi bir biçimlendirmeyi kabul eder.

  3. 3

    Neyin açık başlayacağına karar verin

    Yükleme sırasında hangi satır genişletilmiş olmalıysa o satıra open özniteliğini ekleyin. İlkini açmak, satırların interaktif olduğunu bariz hale getirir.

  4. 4

    Özel olup olmayacağını seçin

    Birini açmak diğerlerini kapatacaksa her details elementine aynı name özniteliğini verin. Okuyucuların satırları karşılaştırmak isteyebileceği durumlarda özniteliği boş bırakın.

  5. 5

    summary stilini düzenleyin

    marker:content-none ile varsayılan işareti kaldırın, ardından summary elementini etiket ve gösterge için normal bir flex konteyneri olarak ele alın.

Features

JavaScript Yok

Geçiş (toggling), klavye aktivasyonu ve durum tarayıcı tarafından yönetilir; bu sayede bileşen hidrasyondan (hydration) önce çalışır ve betikler (scripts) başarısız olursa çalışmaya devam eder.

Varsayılan olarak doğru semantik

Genişletilmiş durum, aria-expanded ayarlamaya veya senkronize tutmaya gerek kalmadan, yardımcı teknolojilere otomatik olarak sunulur.

Daraltıldığında bulunabilir

Tarayıcının sayfada bul (find-in-page) özelliği, div'lerden oluşturulmuş bir JavaScript akordeonunun yapamayacağı şekilde, bir eşleşmeyi ortaya çıkarmak için daraltılmış bir paneli açabilir.

CSS tabanlı gösterge

Ok (chevron) rotasyonu group-open varyantından gelir, yani açık durumu bir durum (state) değişkeni yerine doğrudan stili yönlendirir.

Kodsuz özel (exclusive) mod

Paylaşılan bir name özniteliği, grubun tamamen tarayıcı tarafından yönetilen, aynı anda tek bir öğenin açık olduğu bir akordeon gibi davranmasını sağlar.

Server-component dostu

Durum ve efekt olmadığından, React sürümü Next.js App Router'da use client direktifi olmaksızın sunucuda render edilir.

Common Uses

SSS (FAQ) bölümleri

En yaygın kullanım. Yirmi soru bir ekranlık başlığa sığar ve okuyucular yalnızca kendilerini ilgilendiren ikisini açar.

Filtre grupları

Ürün kenar çubuğunda daraltılabilir kategori, fiyat ve öznitelik grupları, böylece uzun bir filtre seti kısa bir ekranda gezilebilir kalır.

Ayarlar panelleri

Gelişmiş seçenekleri daraltılmış bir satırın altında gruplamak, seçenekleri tamamen gizlemeden bir ayarlar sayfasının anlaşılır kalmasını sağlar.

Dokümantasyon detayları

Ana akışın okunabilir kalması için tam API tablolarını, uzun hata mesajlarını veya isteğe bağlı kurulum adımlarını bir disclosure arkasında saklama.

Accessibility

Customization

Props

PropTypeDefaultDescription
items *{ question: string; answer: string }[]-Akordeon satırları. On iki veya daha az tutun; bundan fazlası için aranabilir bir liste veya ayrı sayfa setleri okuyuculara daha iyi hizmet eder.
defaultOpenIndexnumber0Hangi satırın açık başlayacağı. İlkini açmak, satırların interaktif olduğunu gösterir; hepsini kapalı bırakmak statik başlık listesi olarak algılanabilir.

Why Use These Akordeons?

Yanlış gidebilecek en az şeye sahip sürüm. Durum yok, bağımlılık yok, hidrasyon yok, senkronize edilecek ARIA yok ve JavaScript yüklenmeden önce ve hata verdiğinde çalışan davranış.

Bulunabilir kalır. Daraltılmış bir details içindeki içerik, tarayıcının sayfada bul (find-in-page) özelliğiyle hâlâ ortaya çıkarılabilir; birçok okuyucunun uzun bir SSS'de aslında bu şekilde gezindiği görülür - div tabanlı bir akordeon bu içeriği aramadan sessizce gizler.

React sürümünün use client direktifine ihtiyacı yoktur, bu yüzden sunucuda render edilir. Dolaşımdaki çoğu akordeon bileşeni, sırf tarayıcının zaten izlediği açık durumu izledikleri için tamamen istemci bileşenleridir.

Tips

Frequently Asked Questions

Related Components