Accordion
Organize related content into independently expandable sections.
Usage
Single
Keep one active value while moving and selecting with keyboard or pointer input.
Keep one active value while moving and selecting with keyboard or pointer input.
<!-- Accordion / Single -->
<script setup lang="ts">
import {
AccordionContent, AccordionHeader, AccordionItem,
AccordionRoot, AccordionTrigger,
} from '@sectile/vue/accordion'
const items = ['general', 'deployments', 'danger']
</script>
<template>
<AccordionRoot
:items="items"
type="single"
:collapsible="true"
>
<AccordionItem v-for="item in items" :key="item" :value="item">
<AccordionHeader><AccordionTrigger>{{ item }}</AccordionTrigger></AccordionHeader>
<AccordionContent>Settings for {{ item }}</AccordionContent>
</AccordionItem>
</AccordionRoot>
</template>Multiple
Select several values independently without collapsing the existing selection.
Select several values independently without collapsing the existing selection.
<!-- Accordion / Multiple -->
<script setup lang="ts">
import {
AccordionContent, AccordionHeader, AccordionItem,
AccordionRoot, AccordionTrigger,
} from '@sectile/vue/accordion'
const items = ['general', 'deployments', 'danger']
</script>
<template>
<AccordionRoot
:items="items"
type="multiple"
:collapsible="true"
>
<AccordionItem v-for="item in items" :key="item" :value="item">
<AccordionHeader><AccordionTrigger>{{ item }}</AccordionTrigger></AccordionHeader>
<AccordionContent>Settings for {{ item }}</AccordionContent>
</AccordionItem>
</AccordionRoot>
</template>Required
Require one value to remain selected or one section to remain expanded.
Require one value to remain selected or one section to remain expanded.
<!-- Accordion / Required -->
<script setup lang="ts">
import {
AccordionContent, AccordionHeader, AccordionItem,
AccordionRoot, AccordionTrigger,
} from '@sectile/vue/accordion'
const items = ['general', 'deployments', 'danger']
</script>
<template>
<AccordionRoot
:items="items"
type="single"
default-value="deployments"
>
<AccordionItem v-for="item in items" :key="item" :value="item">
<AccordionHeader><AccordionTrigger>{{ item }}</AccordionTrigger></AccordionHeader>
<AccordionContent>Settings for {{ item }}</AccordionContent>
</AccordionItem>
</AccordionRoot>
</template>Controlled
Let the parent own the current value and apply accepted changes back to the component.
Let the parent own the current value and apply accepted changes back to the component.
<!-- Accordion / Controlled -->
<script setup lang="ts">
import {
AccordionContent, AccordionHeader, AccordionItem,
AccordionRoot, AccordionTrigger,
} from '@sectile/vue/accordion'
const items = ['general', 'deployments', 'danger']
</script>
<template>
<AccordionRoot
:items="items"
type="single"
:collapsible="true"
>
<AccordionItem v-for="item in items" :key="item" :value="item">
<AccordionHeader><AccordionTrigger>{{ item }}</AccordionTrigger></AccordionHeader>
<AccordionContent>Settings for {{ item }}</AccordionContent>
</AccordionItem>
</AccordionRoot>
</template>API
Vue package: @sectile/vue/accordion
AccordionRootAccordionItemAccordionHeaderAccordionTriggerAccordionContent
Props
AccordionRootProps
asElement or component rendered for this part.
asChildWhether to merge this part into its single child instead of rendering a wrapper.
collapsibleWhether the final expanded item may be collapsed.
defaultValueInitial value used when the component owns its state.
disabledWhether interaction is unavailable.
disabledItemsItem values excluded from focus and selection.
itemsOrdered item values managed by the component.
modelValueCurrent value when state is controlled by the parent.
readonlyWhether the value can be inspected but not changed.
typeSelection or behavior mode used by the component.
AccordionItemProps
asElement or component rendered for this part.
asChildWhether to merge this part into its single child instead of rendering a wrapper.
disabledWhether interaction is unavailable.
valueCurrent value exposed by this contract.
AccordionPartProps
asElement or component rendered for this part.
asChildWhether to merge this part into its single child instead of rendering a wrapper.
Slots
AccordionRootSlotProps
disabledWhether interaction is unavailable.
readonlyWhether the value can be inspected but not changed.
valueCurrent value exposed by this contract.
AccordionItemSlotProps
disabledWhether interaction is unavailable.
openWhether the associated popup or disclosure is open.
valueCurrent value exposed by this contract.
Events
AccordionRoot
update:modelValueEmitted when the component requests a new controlled value.
Other types
AccordionType
type AccordionType = 'single' | 'multiple'AccordionValue
type AccordionValue = string | readonly string[]AccordionValueChangeHandler
type AccordionValueChangeHandler = (value: AccordionValue) => voidParts
Shared scope: [data-scope="accordion"]. Combine it with a part selector to keep styles local to this component.
| Part | Selector | Role | Extra attributes |
|---|---|---|---|
root | [data-part="root"] | Defines the component boundary and owns its composed parts. | — |
item | [data-part="item"] | Represents one selectable or actionable item. | — |
header | [data-part="header"] | Provides the semantic heading for an expandable item. | — |
trigger | [data-part="trigger"] | Opens, closes, or activates the associated content. | — |
content | [data-part="content"] | Contains the component content shown for the active state. | — |
Keyboard interaction
| Key | Behavior |
|---|---|
| Enter / Space | Toggle the focused section. |
| Arrow Up / Arrow Down | Move focus between section triggers. |
| Home / End | Move focus to the first or last section trigger. |
Accessibility
Section triggers expose expanded state and control their content regions.
See the corresponding WAI-ARIA pattern for the host accessibility contract.
