Skip to content
Esc
↑↓navigate↵open⌘Jpreview
On this page

Native Accordion for Astro

Group native HTML disclosures, choose an initially open answer, and style the summary and indicator.

Where do we meet?
Meet at the print studio on the ground floor.
What should I bring?
Bring a sketch. The studio supplies paper and ink.

Installation

bunx --bun shadcn@latest add @gnostic/native-accordion

Usage

---
import { NativeAccordion } from "@/components/ui/native-accordion"
---

<NativeAccordion
  summary="Can I bring a guest?"
  content="Yes. Add their name when you book."
  open
/>

Each item renders a details element. Set the same name on related items to allow at most one open answer. Use a distinct name for each group on the page. Omit name to let readers open answers independently. Use open on the item that should start expanded.

Compose the parts

Use NativeAccordionDetails for the root. Put NativeAccordionSummary first and NativeAccordionContent after it. Each part accepts the HTML attributes for its element, including class. The summary supplies a chevron. Use its optional indicator slot to replace it.

Where can I collect my print?

Bring your receipt to the studio desk.

NativeAccordion slots

PropType
summary?Astro content

Sets the visible label in the summary.

TypeAstro content
Defaultsummary prop
indicator?Astro content

Replaces the decorative icon. This slot is also available on NativeAccordionSummary when composing the parts.

TypeAstro content
DefaultChevron down

Theme and layout

Set the border and radius on NativeAccordionDetails, the focus and label styles on NativeAccordionSummary, and the answer spacing on NativeAccordionContent. Templates can also target the native-accordion, native-accordion-summary, native-accordion-indicator, and native-accordion-content data slots.

Props

PropType
summary?string

Label on the summary. The summary slot can supply markup.

Typestring
content?string

Text shown when open. The default slot can supply markup.

Typestring

The default slot on NativeAccordion replaces the content text.

Tab moves focus to the summary. Enter and Space toggle the answer with JavaScript disabled. The open and close animation respects the reader’s reduced-motion setting.