Accordion â Svelte
Accordion component â Svelte.
Accordion component
Expandable panels with single or multiple open. Keyboard (Arrow keys, Home, End, Enter/Space) and ARIA.
Props
items(array, required) â Objects withid,title, optionalcontent(HTML string)id(string, optional) â Unique accordion idallowMultiple(boolean, optional) â Allow multiple panels open (default: false)defaultExpanded(string | string[], optional) â ID(s) to expand by defaultclass(string, optional) â Additional CSS classes
Single open (default)
Live example
Content for section two.
Content for section three.
Allow multiple
Live example
Content for section three.
Usage
svelte svelte
<script>
import Accordion from './components/svelte/Accordion.svelte';
</script>
<Accordion
items={[
{ id: 'a', title: 'Panel A', content: '<p>Content A.</p>' },
{ id: 'b', title: 'Panel B', content: '<p>Content B.</p>' },
]}
defaultExpanded="a"
/>
<Accordion items={items} allowMultiple />