Raccourci clavier : Ctrl + K
Commencer

Accordéon

VAccordion regroupe des sections repliables fondées sur des éléments natifs <details>.

Utilisation

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>

Exemples

Variantes

flat laisse le groupe sans cadre. outline ajoute une bordure, elevated une surface surélevée avec une ombre et filled une surface atténuée.

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>

Une section à la fois

Une seule section reste ouverte par défaut. Activez multiple pour en conserver plusieurs ouvertes.

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>

Sous-titres et icônes

Ajoutez icon et subtitle, ou utilisez leurs slots pour du contenu personnalisé.

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>

Icônes d'ouverture et de fermeture

Sans collapseIcon, l’icône tourne à l’ouverture. Avec cette prop, les icônes s’échangent.

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>

Sections désactivées

Les sections désactivées ne s’ouvrent ni ne se ferment, et la navigation au clavier les ignore.

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
PropTypeDéfaut
multiplebooleanfalse
Permet de conserver plusieurs sections ouvertes.
variantAccordionVariant'flat' | 'outline' | 'elevated' | 'filled''flat'
Groupe sans cadre, ou encadré par une bordure, une ombre ou un fond atténué.
expandIconIconSourceexpand_more
Icône de section fermée. Tourne à l’ouverture sauf si collapseIcon est défini.
collapseIconIconSourceaucune
Icône de section ouverte remplaçant l’icône tournée.
VAccordionItem
PropTypeDéfaut
titlestringaucune
Titre de section. Remplacé par le slot title.
subtitlestringaucune
Seconde ligne sous le titre. Remplacée par son slot.
iconIconSourceaucune
Icône avant le titre. Remplacée par son slot.
defaultOpenbooleanfalse
État ouvert initial. Les modifications ultérieures ne pilotent pas la section.
disabledbooleanfalse
Désactive les interactions.
v-model:openboolean | nullnull
État ouvert à observer ou à piloter.

Slots

VAccordion
SlotType
default{}
Enfants VAccordionItem.
VAccordionItem
SlotType
default{}
Contenu déplié.
title{}
Contenu remplaçant le titre.
subtitle{}
Contenu remplaçant le sous-titre.
icon{}
Contenu remplaçant l’icône.

Types

Types utilisés dans les tables d’API. Importez les types exportés depuis 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