Accordion
Stacked sections that expand one (or several) at a time.
Example
Invoices are sent on the 1st of each month.
Up to 10 seats on this plan.
Managed by your organization.
Exports include all files.
<div class="full"> <focsd-accordion> <focsd-accordion-item heading="Billing" open ><p>Invoices are sent on the 1st of each month.</p></focsd-accordion-item > <focsd-accordion-item heading="Members" ><p>Up to 10 seats on this plan.</p></focsd-accordion-item > <focsd-accordion-item heading="Security" disabled ><p>Managed by your organization.</p></focsd-accordion-item > <focsd-accordion-item heading="Data export" ><p>Exports include all files.</p></focsd-accordion-item > </focsd-accordion></div>Usage
Import the module once, then use the tag like any HTML element. Every framework below renders the same element; see Frameworks for setup.
<script type="module"> import '@focsd-dev/components/focsd-accordion.js';</script>
<focsd-accordion>…</focsd-accordion>import { Accordion } from '@focsd-dev/react';
export function Example() { return <Accordion>…</Accordion>;}<script setup>import '@focsd-dev/components/focsd-accordion.js';</script>
<template> <focsd-accordion>…</focsd-accordion></template>// Add CUSTOM_ELEMENTS_SCHEMA to the component's schemas, then:import '@focsd-dev/components/focsd-accordion.js';
// template<focsd-accordion>…</focsd-accordion><script> import '@focsd-dev/components/focsd-accordion.js';</script>
<focsd-accordion>…</focsd-accordion>API
Attributes
| Attribute | Property | Type | Default |
|---|---|---|---|
multiple | multiple | boolean | false |
Slots
| Slot | Description |
|---|---|
(default) | Default content. |
Accessibility
- Items with the same
nameform an exclusive group, like<details name>(the accordion does this for its own items unlessmultiple). - Each item renders a heading (level from
level, default 3) wrapping a<button aria-expanded aria-controls>, and arole="region"panel labeled by the button. - Set
multipleto allow several open items.
Keyboard
| Key | Action |
|---|---|
| Enter / Space | Toggle the section |
| Arrow Up / Down | Previous / next header (wrapping) |
| Home / End | First / last header |
Ask the docs
Hi, what are you building?
Ask about any component, theming, forms or frameworks. I answer with the right component, a snippet and a link to its docs.