Accordion
Accordion
Vertically stacked interactive sections to organize content.
Is it accessible?
Yes. It uses native HTML details/summary elements for full keyboard navigation and screen reader support.
Is it styled?
Yes. It comes with default styles using Tailwind CSS that you can customize.
12345678910111213141516171819202122232425262728293031package showcase import ( popui "github.com/invopop/popui/go" "github.com/invopop/popui/go/props" ) templ AccordionDefault() { <div class="w-full space-y-2"> @popui.Accordion(props.Accordion{Open: true}) { @popui.AccordionTrigger() { Is it accessible? } @popui.AccordionContent() { @popui.Description() { Yes. It uses native HTML details/summary elements for full keyboard navigation and screen reader support. } } } @popui.Accordion() { @popui.AccordionTrigger() { Is it styled? } @popui.AccordionContent() { @popui.Description() { Yes. It comes with default styles using Tailwind CSS that you can customize. } } } </div> }
API Reference
Accordion
The main accordion container component using HTML details element.
| Name | Type | Default | Description |
|---|---|---|---|
ID | string | - | Unique identifier for the accordion element |
Class | string | - | Additional CSS classes to merge with base styles |
Attributes | templ.Attributes | - | Additional HTML attributes to apply to the details element |
Open | bool | false | Whether the accordion is initially expanded |
AccordionTrigger
Clickable trigger element that toggles the accordion item.
| Name | Type | Default | Description |
|---|---|---|---|
ID | string | - | Unique identifier for the trigger element |
Class | string | - | Additional CSS classes to merge with base styles |
Attributes | templ.Attributes | - | Additional HTML attributes to apply to the summary element |
AccordionContent
Collapsible content area of the accordion item.
| Name | Type | Default | Description |
|---|---|---|---|
ID | string | - | Unique identifier for the content element |
Class | string | - | Additional CSS classes to merge with base styles |
Attributes | templ.Attributes | - | Additional HTML attributes to apply to the content div |