component :: FAQ

The .faq component groups details/summary disclosures into the classic FAQ accordion — native behavior, zero JavaScript.

Does this need JavaScript?

No. The browser’s own details element does all the work.

How does exclusive-open work?

Every item in this group shares name=“demo”, so the browser only keeps one open. Remove the name and items open independently.

Is it keyboard accessible?

Natively: the summary is focusable and toggles with Enter/Space.

FileDescriptionSource
component.faq.cssGroup spacingGithub
elements.interactive.cssThe details/summary styling + chevronGithub
Faq.astro, FaqItem.astroThe Astro componentsGithub
--faq-spacing in default themeTheme tokenGithub

HTML

<div class="faq">
<details class="faq_item" name="faq">
<summary>Does this need JavaScript?</summary>
<div class="faq_content">
<p>No. The browser's own details element does all the work.</p>
</div>
</details>
<details class="faq_item" name="faq" open>
<summary>How does exclusive-open work?</summary>
<div class="faq_content">
<p>Every item shares the same name attribute.</p>
</div>
</details>
</div>

Giving every item the same name makes the group exclusive-open (opening one closes the others). It is a progressive enhancement: browsers that don’t support exclusive accordions simply let several items stay open, which is a perfectly fine FAQ too.

Custom properties

PropertyDescription
--faq-spacingGap between items.

The item visuals come from the details element styling; there is nothing FAQ-specific to retheme.

Astro component

Faq takes only class and passes everything else to its root <div>. Items go in the default slot.

FaqItem

PropTypeDefaultDescription
questionstringThe summary text. Required.
openbooleanfalseRender the item open.
namestringundefinedSame name on every item of a group = native exclusive-open.
classstringundefinedAdditional CSS classes.

The default slot is the answer.

Examples