Accordion
Stacked sections that open in place, one or many at a time.
Orders leave the studio within two working days. You get a note when yours is on its way.
Send anything back within 30 days. Prints need to arrive flat and unframed.
Keep prints out of direct sun. A dry cloth is all the cleaning they need.
Source
<script lang="ts">
import 'portal-bits/styles.css';
import 'portal-bits/tokens.css';
import type { Snippet } from 'svelte';
let { children }: { children: Snippet } = $props();
</script>
{@render children()}
<script lang="ts">
import AccordionExample from './AccordionExample.svelte';
</script>
<AccordionExample multiple={false} />
<script lang="ts">
import { Accordion } from 'portal-bits';
let { multiple = false }: { multiple?: boolean } = $props();
let open = $state(['shipping']);
</script>
{#snippet shipping()}
Orders leave the studio within two working days. You get a note when yours is on its way.
{/snippet}
{#snippet returns()}
Send anything back within 30 days. Prints need to arrive flat and unframed.
{/snippet}
{#snippet care()}
Keep prints out of direct sun. A dry cloth is all the cleaning they need.
{/snippet}
<div class="frame">
<Accordion
bind:value={open}
{multiple}
items={[
{ value: 'shipping', title: 'When will my order ship?', content: shipping },
{ value: 'returns', title: 'Can I return a print?', content: returns },
{ value: 'care', title: 'How do I look after it?', content: care },
]}
/>
</div>
<style>
.frame {
width: 480px;
max-width: 100%;
}
</style>
API reference
These tables list the props and snippets that Accordion declares. Attributes passed through to an element or primitive are listed under Forwarded attributes, not here.
Props
| Name | Type | Default | Required | Binding | Description |
|---|---|---|---|---|---|
items | AccordionItem[] | None | Yes | One-way | Sections as `{ value, title, content, disabled? }`. `content` is a Snippet. |
value | string[] | [] | No | Bindable | The open sections. Single mode keeps at most one. |
multiple | boolean | false | No | One-way | Lets several sections stay open. |
headingLevel | 2 | 3 | 4 | 5 | 6 | 3 | No | One-way | The heading level around each trigger. |
class | string | "" | No | One-way | Extra classes, added after the component classes. |
Forwarded attributes
None. Accordion forwards no attributes.
The primitive underneath is a Bits UI peer dependency. Its own options are documented in the Bits UI Accordion documentation. Only the props listed on this page are part of the Accordion contract. No data attributes are documented as stable.
Limits
- `value` is always an array, in both modes, so switching `multiple` keeps one type.
- The hairline rows, round chevron, and height animation are an adaptation.
- Reduced motion removes the height animation. The open state still changes.