Skip to content

Accordion

Grouped disclosure sections with expand/collapse all. Use to structure related content that users can selectively reveal.


Demo

Default (separators)

Hvad er design tokens?

Design tokens er de mindste byggesten i et designsystem — navngivne værdier for farver, typografi, spacing, radier og shadows.

Hvordan installerer jeg Grundtone?

Installér med pnpm add @grundtone/vue og importér komponenterne i dit projekt.

Understøtter Grundtone dark mode?

Ja. Tema-switching sker via CSS custom properties. Alle farver defineres som semantiske tokens der automatisk skifter mellem lys og mørk palette.

Bordered

Konfiguration

Grundtone konfigureres via defineGrundtoneConfig() i core-pakken.

Prefix-system

Alle klasser prefixes med gt- som default. Kan overrides via config.

Icon-system

SVG-ikoner registreres i core og bruges via GTIcon-komponenten.

Card

Vue 3

Fuld Vue 3 komponentbibliotek med Composition API, TypeScript og Vite-baseret build.

Nuxt 3

Nuxt-modul der auto-importerer komponenter og injicerer CSS.

React Native

Native komponenter med tema-provider og platform-specifikke shadows og spacing.

Transitions

transition="slide" (default)

Smooth height animation

Panelet glider op og ned med CSS grid-trick.

transition="fade"

Opacity fade

Panelet fader ind og ud.

transition="none"

Instant toggle


When to use

  • Multiple related sections where users need only a few at a time
  • FAQ pages, help sections, settings panels
  • Mobile-first content where screen space is limited

When not to use

  • For content most users need — keep it visible
  • As a replacement for page navigation or step-by-step flows
  • For small amounts of content that could be shown directly
  • Nested inside other accordions — use headings to group instead

Installation

bash
pnpm add @grundtone/vue

Usage

Default (separators)

vue
<template>
  <GTAccordion>
    <GTAccordionItem heading="Section one">
      <p>Content for section one.</p>
    </GTAccordionItem>
    <GTAccordionItem heading="Section two">
      <p>Content for section two.</p>
    </GTAccordionItem>
  </GTAccordion>
</template>

Bordered

vue
<template>
  <GTAccordion variant="bordered">
    <GTAccordionItem heading="Configuration">
      <p>Config details here.</p>
    </GTAccordionItem>
  </GTAccordion>
</template>

Card

vue
<template>
  <GTAccordion variant="card">
    <GTAccordionItem heading="Vue 3">
      <p>Full component library with Composition API.</p>
    </GTAccordionItem>
  </GTAccordion>
</template>

With summary and pre-opened item

vue
<template>
  <GTAccordion>
    <GTAccordionItem heading="Getting started" summary="Quick guide" :open="true">
      <p>Start here for a quick overview.</p>
    </GTAccordionItem>
  </GTAccordion>
</template>

Without toggle all

vue
<template>
  <GTAccordion :show-toggle-all="false">
    <GTAccordionItem heading="Section">
      <p>No toggle-all button.</p>
    </GTAccordionItem>
  </GTAccordion>
</template>

Accordion Props

PropTypeDefaultDescription
variant'default' | 'bordered' | 'card''default'Visual variant
showToggleAllbooleantrueShow "Show all / Hide all" button
toggleAllLabelOpenstring'Vis alle'Label for show-all state
toggleAllLabelClosestring'Skjul alle'Label for hide-all state
ariaLabelstring'Accordion'Accessible label for the region

AccordionItem Props

PropTypeDefaultDescription
headingstringrequiredSection heading text
summarystringOptional short description under heading
openbooleanfalseStart in open state
headingLevel2 | 3 | 43Heading element level

Slots

Accordion

SlotDescription
defaultAccordionItem children

AccordionItem

SlotDescription
defaultSection content

Accessibility

  • Each header is a <button> with aria-expanded and aria-controls
  • Content panels have role="region" with aria-labelledby
  • Keyboard: Enter/Space toggles, Tab navigates between headers
  • Heading level is configurable (h2/h3/h4) for document outline
  • Plus/minus icon is decorative (aria-hidden="true")
  • Multiple sections can be open simultaneously

CSS Classes

ClassElement
.gt-accordionRoot container
.gt-accordion--defaultSeparator variant
.gt-accordion--borderedOutlined variant
.gt-accordion--cardBoxed variant
.gt-accordion__toggle-allShow/hide all button
.gt-accordion__itemSingle section
.gt-accordion__item--openOpen state
.gt-accordion__headerClickable trigger button
.gt-accordion__iconPlus/minus indicator
.gt-accordion__headingHeading text
.gt-accordion__summaryOptional summary
.gt-accordion__panelContent panel
.gt-accordion__bodyInner body

Design system

The CSS-only version of this component is documented in the Design System — Accordion reference.