Skip to content
portalbits
Home Docs GitHub(opens in a new tab)

Guides

Get startedFoundationsMotion

Components

All components

Buttons

ButtonIconButton

Inputs

InputSelectTextareaSlider

Selection

CheckboxToggleToggleGroupSwitchRadioGroup

Identity

AvatarBadge

Overlays

DialogPopoverTooltipDropdownMenuAlertDialog

Disclosure

TabsAccordion

Cards

AppCardArticleCardFeatureCard

Content

CarouselSectionHeaderEmptyStateAlertProgressSeparatorRowListRow

Chrome

PortalShellSidebarNavMobileNavTopBarAuthFrameColorSelectorFloatingNav

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.
Variations

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

NameTypeDefaultRequiredBindingDescription
itemsAccordionItem[]NoneYesOne-waySections as `{ value, title, content, disabled? }`. `content` is a Snippet.
valuestring[][]NoBindableThe open sections. Single mode keeps at most one.
multiplebooleanfalseNoOne-wayLets several sections stay open.
headingLevel2 | 3 | 4 | 5 | 63NoOne-wayThe heading level around each trigger.
classstring""NoOne-wayExtra 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.

Related

  • Tabs
  • RowList
Previous Tabs Next AppCard

On this page

  • Preview
  • Source
  • API reference
  • Props
  • Forwarded attributes
  • Limits