Keyboard shortcut: Ctrl + K
Get started

Accordion

VAccordion groups collapsible sections built with native <details> elements.

Usage

vue
Does it work with Nuxt?
Yes. The package is SSR-safe and ships as ESM.
Is there a Tailwind preset?
No. The tokens are custom properties, which any framework can read.
<script setup lang="ts">
import { VAccordion, VAccordionItem } from 'vectis-ui'
</script>

<template>
  <VAccordion>
    <VAccordionItem title="Does it work with Nuxt?" default-open>
      Yes. The package is SSR-safe and ships as ESM.
    </VAccordionItem>
    <VAccordionItem title="Is there a Tailwind preset?">
      No. The tokens are custom properties, which any framework can read.
    </VAccordionItem>
  </VAccordion>
</template>

Examples

Variants

flat leaves the group unframed. outline adds a border, elevated a raised surface with a shadow and filled a muted surface.

vue
Flat, the default
Nothing is drawn around the group, which lets it sit on the surface behind it.
No background, no border
Reach for it when the page already provides the frame.
Outline
A border on the page surface and rounded corners, so the group reads as a card.
Its own surface
Reach for it when the accordion has to stand apart from what surrounds it.
Elevated
A raised surface with a shadow and no border.
Lifted from the page
Reach for it when the group floats above a busy background.
Filled
A muted surface with no border.
Fewer lines
Reach for it on a page that already has a lot of rules.
<script setup lang="ts">
import { VAccordion, VAccordionItem } from 'vectis-ui'
</script>

<template>
  <VAccordion>
    <VAccordionItem title="Flat, the default" default-open>
      Nothing is drawn around the group, which lets it sit on the surface behind it.
    </VAccordionItem>
    <VAccordionItem title="No background, no border">
      Reach for it when the page already provides the frame.
    </VAccordionItem>
  </VAccordion>

  <VAccordion variant="outline">
    <VAccordionItem title="Outline" default-open>
      A border on the page surface and rounded corners, so the group reads as a card.
    </VAccordionItem>
    <VAccordionItem title="Its own surface">
      Reach for it when the accordion has to stand apart from what surrounds it.
    </VAccordionItem>
  </VAccordion>

  <VAccordion variant="elevated">
    <VAccordionItem title="Elevated" default-open>
      A raised surface with a shadow and no border.
    </VAccordionItem>
    <VAccordionItem title="Lifted from the page">
      Reach for it when the group floats above a busy background.
    </VAccordionItem>
  </VAccordion>

  <VAccordion variant="filled">
    <VAccordionItem title="Filled" default-open>A muted surface with no border.</VAccordionItem>
    <VAccordionItem title="Fewer lines">
      Reach for it on a page that already has a lot of rules.
    </VAccordionItem>
  </VAccordion>
</template>

One section at a time

One section stays open by default. Enable multiple to keep several open.

vue
How long does delivery take?
Two working days in France, five anywhere else in Europe.
Do you ship outside Europe?
Yes, to twenty-eight countries. The rate is shown at checkout.
Can I change the address after ordering?
Until the parcel is handed to the carrier, from the order page.
What can I return?
Anything unworn, within thirty days of delivery.
Who pays for the return?
We do, once per order. The label is in your account.
When is the refund issued?
Within three working days of the parcel reaching the warehouse.
<script setup lang="ts">
import { VAccordion, VAccordionItem } from 'vectis-ui'
</script>

<template>
  <VAccordion>
    <VAccordionItem title="How long does delivery take?" default-open>
      Two working days in France, five anywhere else in Europe.
    </VAccordionItem>
    <VAccordionItem title="Do you ship outside Europe?">
      Yes, to twenty-eight countries. The rate is shown at checkout.
    </VAccordionItem>
    <VAccordionItem title="Can I change the address after ordering?">
      Until the parcel is handed to the carrier, from the order page.
    </VAccordionItem>
  </VAccordion>

  <VAccordion variant="outline" multiple>
    <VAccordionItem title="What can I return?" default-open>
      Anything unworn, within thirty days of delivery.
    </VAccordionItem>
    <VAccordionItem title="Who pays for the return?" default-open>
      We do, once per order. The label is in your account.
    </VAccordionItem>
    <VAccordionItem title="When is the refund issued?">
      Within three working days of the parcel reaching the warehouse.
    </VAccordionItem>
  </VAccordion>
</template>

Subtitles and icons

Add icon and subtitle, or use their slots for custom content.

vue
NotificationsEmail and in-app alerts
Choose which events reach you, and where.
AvailabilityWorking hours and time zone
The hours during which your team can be reached.
DocumentsContracts and invoices
Everything signed or billed on this account.
<script setup lang="ts">
import { VAccordion, VAccordionItem } from 'vectis-ui'
import { description, notifications, schedule } from 'vectis-ui/icons'
</script>

<template>
  <VAccordion variant="outline">
    <VAccordionItem
      :icon="notifications"
      title="Notifications"
      subtitle="Email and in-app alerts"
      default-open
    >
      Choose which events reach you, and where.
    </VAccordionItem>
    <VAccordionItem :icon="schedule" title="Availability" subtitle="Working hours and time zone">
      The hours during which your team can be reached.
    </VAccordionItem>
    <VAccordionItem :icon="description" title="Documents" subtitle="Contracts and invoices">
      Everything signed or billed on this account.
    </VAccordionItem>
  </VAccordion>
</template>

Expand and collapse icons

Without collapseIcon, the expand icon rotates when open. With it, the icons switch.

vue
Where do these two icons come from?
From the icon set wired into the application, since both are given here as names.
And without a collapse icon?
The expand icon stays in place and is rotated when the section opens.
<script setup lang="ts">
import { VAccordion, VAccordionItem } from 'vectis-ui'
</script>

<template>
  <VAccordion variant="outline" expand-icon="add" collapse-icon="remove">
    <VAccordionItem title="Where do these two icons come from?" default-open>
      From the icon set wired into the application, since both are given here as names.
    </VAccordionItem>
    <VAccordionItem title="And without a collapse icon?">
      The expand icon stays in place and is rotated when the section opens.
    </VAccordionItem>
  </VAccordion>
</template>

Disabled sections

Disabled sections cannot be toggled and are skipped by keyboard navigation.

vue
Personal details
Your name, your address and how we may contact you.
Payment methods
Available once your email address has been confirmed.
Delivery preferences
Available once a payment method has been added.
Privacy
What we store, and for how long.
<script setup lang="ts">
import { VAccordion, VAccordionItem } from 'vectis-ui'
</script>

<template>
  <VAccordion variant="outline">
    <VAccordionItem title="Personal details" default-open>
      Your name, your address and how we may contact you.
    </VAccordionItem>
    <VAccordionItem title="Payment methods" disabled>
      Available once your email address has been confirmed.
    </VAccordionItem>
    <VAccordionItem title="Delivery preferences" disabled>
      Available once a payment method has been added.
    </VAccordionItem>
    <VAccordionItem title="Privacy"> What we store, and for how long. </VAccordionItem>
  </VAccordion>
</template>

API

Props

VAccordion
PropTypeDefault
multiplebooleanfalse
Allows several sections to remain open.
variantAccordionVariant'flat' | 'outline' | 'elevated' | 'filled''flat'
Unframed group, or framed by a border, a shadow or a muted fill.
expandIconIconSourceexpand_more
Closed-section icon. Rotates when open unless collapseIcon is set.
collapseIconIconSourcenone
Open-section icon replacing the rotated expand icon.
VAccordionItem
PropTypeDefault
titlestringnone
Section heading. Replaced by the title slot.
subtitlestringnone
Second line below the title. Replaced by its slot.
iconIconSourcenone
Icon before the title. Replaced by its slot.
defaultOpenbooleanfalse
Initial open state. Later changes do not control the section.
disabledbooleanfalse
Disables interaction.
v-model:openboolean | nullnull
Open state to observe or control.

Slots

VAccordion
SlotType
default{}
VAccordionItem children.
VAccordionItem
SlotType
default{}
Expanded content.
title{}
Content replacing the title.
subtitle{}
Content replacing the subtitle.
icon{}
Content replacing the icon.

Types

Types used in the API tables. Import exported types from vectis-ui.

export interface BuiltinIcon {
  name: string
  paths: readonly [string] | readonly [string, string]
}
export type IconRender =
  | { path: string; viewBox?: string }
  | { component: Component; props?: Record<string, unknown> }
  | { src: string }
  | { text: string; class?: string }
  | { class: string }
export type IconSource = string | BuiltinIcon | IconRender