Accordion
Sections that fold. It is built on <details> and <summary>, so the open state, the keyboard behaviour and in-page search all come from the browser.
Usage
Does it work with Nuxt?
Is there a Tailwind preset?
Examples
Variants
variant sets the group decoration: flat (default) draws nothing, outlined adds a raised background, a border and rounded corners.
Flat, the default
No background, no border
Outlined
Its own surface
One section at a time
A group keeps a single section open by default. multiple allows several sections to stay open at the same time. VSideNavigation has the opposite default and the opposite prop, exclusive: a sidebar usually lets several sections stay open.
How long does delivery take?
Do you ship outside Europe?
Can I change the address after ordering?
What can I return?
Who pays for the return?
When is the refund issued?
Subtitles and icons
icon places an icon before the title and subtitle adds a second line under it. The #icon and #subtitle slots take markup instead of plain text.
NotificationsEmail and in-app alerts
AvailabilityWorking hours and time zone
DocumentsContracts and invoices
Compact
compact reduces every padding by 4px, leaving the text and the icons at their size.
RuntimeNode 20.11
Package managerpnpm 11
Module formatESM only
Expand and collapse icons
expandIcon replaces the chevron. Adding collapseIcon swaps the two icons when a section opens, instead of rotating the first one.
Where do these two icons come from?
And without a collapse icon?
Disabled sections
disabled prevents a section from being opened and greys it out. The keyboard steps over it.
Personal details
Payment methods
Delivery preferences
Privacy
API
Props
| Prop | Type | Default |
|---|---|---|
multiple | boolean | false |
Lets the reader keep several sections open at once. Left out, only one stays open and opening one closes the last, which the browser does on its own once every item shares a <details> name. | ||
variant | AccordionVariant'flat' | 'outlined' | 'flat' |
How the group is decorated. flat draws nothing and lets the accordion sit on the surface behind it; outlined gives it a raised background, a border and rounded corners, so it reads as a card. | ||
expandIcon | IconSource | expand_more |
| The icon shown on a closed section. It is a chevron, which rotates by 180° when the section opens. | ||
collapseIcon | IconSource | none |
| The icon shown on an open section. Leave it out and the expand icon is rotated instead; give one and the two are swapped. | ||
compact | boolean | false |
| Reduced density: every padding loses 4px, while the text and the icons keep their size. | ||
| Prop | Type | Default |
|---|---|---|
title | string | none |
The heading of the section, the line that stays visible when it is closed. Use the #title slot when the heading needs markup rather than plain text. | ||
subtitle | string | none |
A second line under the title, for a short explanation or a status. The #subtitle slot replaces it when markup is needed. | ||
icon | IconSource | none |
An icon before the title. The #icon slot replaces it. | ||
defaultOpen | boolean | false |
| Renders the section already open. Only its initial value is read: the browser owns the state afterwards, so changing this later will not close a section the reader has opened. | ||
disabled | boolean | false |
| Makes the section inert. It can no longer be opened, the keyboard steps over it, and it greys out through the colour tokens. | ||
v-model:open | boolean | null | null |
Whether the section is open, when you want to drive or observe it. Left unbound, the browser keeps that state to itself and defaultOpen gives only the initial value. | ||
Slots
| Slot | Type |
|---|---|
default | {} |
The VAccordionItems that make up the group. | |
| Slot | Type |
|---|---|
default | {} |
| The content revealed when the section is open. | |
title | {} |
A title made of markup, which replaces the title prop. | |
subtitle | {} |
A subtitle made of markup, which replaces the subtitle prop. | |
icon | {} |
Free content before the title, which takes the place of icon. | |
Types
The types the tables above name, written as the library declares them. The ones carrying export can be imported from vectis-ui to type your own code; the others are the shape of what a slot hands out.
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