An accordion built on native <details> elements. A shared name attribute makes the browser keep only one item open, with no JavaScript and no state. Where the browser supports ::details-content and interpolate-size, items open with a smooth height transition.
Browser Support
Groups expandable sections
Animates the content height
Targets the expandable content
Controls visibility of closed content
Animates opening and closing
Preview
Open one question, then another: the first one closes by itself.
How long does delivery take?
Orders within the city arrive the next day. Other regions take two to five days depending on the distance.
Can I return an item?
Yes, within 14 days if the item has not been used. The refund goes to the same card.
Do you work on weekends?
The warehouse is closed on Sundays, but orders are accepted around the clock.
How do I change my address?
Open the order and press Edit until it is handed to the courier.
Installation
Usage
import { DetailsAccordion } from "@/components/ui/details-accordion"
const items = [
{ title: "How long does delivery take?", content: "Next day within the city." },
{ title: "Can I return an item?", content: "Yes, within 14 days." },
]
export default function Faq() {
return <DetailsAccordion items={items} />
}Examples
Several open items
multiple drops the shared name, so items open independently.
Ingredients
Flour, water, salt and a little yeast.
Storage
Keep in a paper bag for up to three days.
Allergens
Contains gluten. May contain traces of sesame.
<DetailsAccordion items={items} multiple />Card variant
variant="card" puts every item in its own card. The first one here is open from the start through defaultOpen.
How long does delivery take?
Orders within the city arrive the next day. Other regions take two to five days depending on the distance.
Can I return an item?
Yes, within 14 days if the item has not been used. The refund goes to the same card.
Do you work on weekends?
The warehouse is closed on Sundays, but orders are accepted around the clock.
How do I change my address?
Open the order and press Edit until it is handed to the courier.
<DetailsAccordion
variant="card"
items={[
{ title: "How long does delivery take?", content: "…", defaultOpen: true },
{ title: "Can I return an item?", content: "…" },
]}
/>As on the GooseUI home page
variant="framed" with numbered gives the FAQ from the home page: a dashed outer frame, a filled inner card and big numbers. It is plain details, so it works without JavaScript.
01How long does delivery take?
Orders within the city arrive the next day. Other regions take two to five days depending on the distance.
02Can I return an item?
Yes, within 14 days if the item has not been used. The refund goes to the same card.
03Do you work on weekends?
The warehouse is closed on Sundays, but orders are accepted around the clock.
04How do I change my address?
Open the order and press Edit until it is handed to the courier.
<DetailsAccordion
variant="framed"
numbered
items={[
{ title: "What is GooseUI?", content: "…", defaultOpen: true },
{ title: "Is it free?", content: "…" },
]}
/>Single items
DetailsAccordionItem works alone. Give several items the same name to link them anywhere on the page.
Ingredients
Storage
import { DetailsAccordionItem } from "@/components/ui/details-accordion"
<div className="grid gap-4 sm:grid-cols-2">
<DetailsAccordionItem name="product-info" variant="card" title="Ingredients">
Flour, water, salt and a little yeast.
</DetailsAccordionItem>
<DetailsAccordionItem name="product-info" variant="card" title="Storage">
Keep in a paper bag for up to three days.
</DetailsAccordionItem>
</div>Props
| Prop | Type | Default | Description |
|---|---|---|---|
| items | DetailsAccordionItemData[] | - | Items: title, content, optional id and defaultOpen |
| multiple | boolean | false | Let several items stay open |
| name | string | useId() | Shared name for the exclusive mode. Generated when omitted |
| variant | "line" | "card" | "framed" | "line" | Dividers, separate cards or the framed home page look |
| numbered | boolean | false | Show 01, 02, … before every title |
| itemClassName | string | - | Classes for every item |
| className | string | - | Classes for the wrapper |
Components
| Component | Description |
|---|---|
| DetailsAccordion | List of items from the items array |
| DetailsAccordionItem | One <details> item: title, children, name, defaultOpen, variant and any details attribute |
Features
- No JavaScript: works in Server Components and before hydration
- Find in page: browser search opens a closed item when the match is inside it
- Keyboard: summary is focusable, Enter and Space toggle it
- Reduced motion: the height transition is turned off