---
layout: layouts/component.njk
title: Accordion
description: A vertically stacked set of interactive headings that each reveal a section of content.
toc:
- label: Usage
id: usage
---
{% from "macros/code_preview.njk" import code_preview %}
{% from "macros/code_block.njk" import code_block %}
{% lucide "circle-alert" %}
There is no dedicated accordion component in Basecoat.
{% set code %} {
if (detailsEl !== clickedDetails) {
detailsEl.removeAttribute('open');
}
});
"
>
Is it accessible?
{% lucide "chevron-down", { "class": "text-muted-foreground pointer-events-none size-4 shrink-0 translate-y-0.5 transition-transform duration-200 group-open:rotate-180" } %}
Yes. It adheres to the WAI-ARIA design pattern.
Is it styled?
{% lucide "chevron-down", { "class": "text-muted-foreground pointer-events-none size-4 shrink-0 translate-y-0.5 transition-transform duration-200 group-open:rotate-180" } %}
Yes. It comes with default styles that matches the other components' aesthetic.
Is it animated?
{% lucide "chevron-down", { "class": "text-muted-foreground pointer-events-none size-4 shrink-0 translate-y-0.5 transition-transform duration-200 group-open:rotate-180" } %}
Yes. It's animated by default, but you can disable it if you prefer.
{% endset %}
{{ code_preview("accordion", code | prettyHtml, "w-full max-w-md") }}
Basecoat animates <details> elements by default. Using Alpine.js to handle the open/close state and Tailwind to style the the <details> elements, you can get an accordion component:
{{ code_block(code) }}