Skip to content
iv-ui v0.3.0

Accordion

since 0.1.0

A stack of collapsible sections; one or several can be open.

import { Accordion, AccordionItem } from '@elluzion/iv-ui';

Single

Opening one section closes the previous one.

Node 22 on Linux, with the edge cache in front of every request.

Source· svelte Show Hide
<script lang="ts">
	import { Accordion, AccordionItem } from '@elluzion/iv-ui';
</script>

<Accordion defaultValue="runtime">
	<AccordionItem value="runtime" title="Runtime">
		<p>Node 22 on Linux, with the edge cache in front of every request.</p>
	</AccordionItem>
	<AccordionItem value="build" title="Build">
		<p>Static output is prerendered; the rest is bundled on demand.</p>
	</AccordionItem>
	<AccordionItem value="regions" title="Regions">
		<p>Three regions, one primary and two read replicas.</p>
	</AccordionItem>
</Accordion>
  • Each AccordionItem needs a unique value; the parent tracks the open values.
  • Set multiple to keep several panels open at once.
  • Bind value for controlled state, or use defaultValue for an uncontrolled accordion.

Multiple

multiple keeps every opened section open.

Node 22 on Linux, with the edge cache in front of every request.

Three regions, one primary and two read replicas.

Source· svelte Show Hide
<script lang="ts">
	import { Accordion, AccordionItem } from '@elluzion/iv-ui';
</script>

<Accordion multiple defaultValue={['runtime', 'regions']}>
	<AccordionItem value="runtime" title="Runtime">
		<p>Node 22 on Linux, with the edge cache in front of every request.</p>
	</AccordionItem>
	<AccordionItem value="build" title="Build">
		<p>Static output is prerendered; the rest is bundled on demand.</p>
	</AccordionItem>
	<AccordionItem value="regions" title="Regions">
		<p>Three regions, one primary and two read replicas.</p>
	</AccordionItem>
</Accordion>

Custom trigger

The trigger snippet replaces the title content.

Roles are inherited from the organization; overrides live on the project.

Source· svelte Show Hide
<script lang="ts">
	import { IconShieldLock } from '@tabler/icons-svelte';
	import { Accordion, AccordionItem } from '@elluzion/iv-ui';
</script>

<Accordion defaultValue="access">
	<AccordionItem value="access">
		{#snippet trigger()}
			<span class="trigger">
				<IconShieldLock size={14} />
				Access control
			</span>
		{/snippet}
		<p>Roles are inherited from the organization; overrides live on the project.</p>
	</AccordionItem>
	<AccordionItem value="audit" title="Audit log">
		<p>Every privileged action is recorded with the actor and the request id.</p>
	</AccordionItem>
</Accordion>

<style>
	.trigger {
		display: inline-flex;
		align-items: center;
		gap: var(--iv_spacing-sm);
	}
</style>
import { Accordion, AccordionItem } from '@elluzion/iv-ui';

Accordion

5 props · 1 events · 1 snippets
PropTypeDefaultDescription
multiple booleanfalseAllows several items to stay open at once.
value bindableAccordionValue—Open item value(s). Bind with bind:value for controlled state.
defaultValue AccordionValue—Item(s) open on first render.
disabled booleanfalseDisables interaction and applies the disabled treatment.
className string''Extra classes merged onto the root element.

class, id, style, aria-*, and data-* are forwarded through rest props.

Events

EventHandler typeDescription
onchange(e: CustomEvent<{ value: AccordionValue }>) => voidCalled with { value } after an item opens or closes.

The legacy on:name form is accepted for every event.

Snippets

SnippetTypeDescription
childrenSnippetContent rendered inside the component.

Types

AccordionValue

One open item, or several when multiple is set.

type AccordionValue = string | string[];

AccordionItem

3 props · 0 events · 2 snippets
PropTypeDefaultDescription
value required string—Unique value used by the parent accordion to track this item.
title string''Trigger text. Use the trigger snippet for custom content.
disabled booleanfalseDisables interaction and applies the disabled treatment.

Snippets

SnippetTypeDescription
childrenSnippetPanel content revealed when the item is open.
triggerSnippetCustom trigger content replacing the title.
KeysAction
TabMoves focus to the next trigger.
Enter / SpaceOpens or closes the focused section.
  • Triggers are native buttons with aria-expanded and aria-controls.
  • Panels use role="region" and are labelled by their trigger.
  • Opening and closing respects prefers-reduced-motion.
Class hooks
.iv-accordion.iv-disabled.iv-chevron.iv-item.iv-open.iv-panel.iv-trigger.iv-trigger-label
iv-ui
↑ ↓ navigate ↵ open esc close minisearch · 482 records