Skip to content

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.

Multiple

Select several values independently without collapsing the existing selection.

Select several values independently without collapsing the existing selection.

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.

Build targets and release protection. Expanded

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.

API

Vue package: @sectile/vue/accordion

Components
  • AccordionRoot
  • AccordionItem
  • AccordionHeader
  • AccordionTrigger
  • AccordionContent

Props

AccordionRootProps

as

Element or component rendered for this part.

asChild

Whether to merge this part into its single child instead of rendering a wrapper.

collapsible

Whether the final expanded item may be collapsed.

defaultValue

Initial value used when the component owns its state.

disabled

Whether interaction is unavailable.

disabledItems

Item values excluded from focus and selection.

items

Ordered item values managed by the component.

modelValue

Current value when state is controlled by the parent.

readonly

Whether the value can be inspected but not changed.

type

Selection or behavior mode used by the component.

AccordionItemProps

as

Element or component rendered for this part.

asChild

Whether to merge this part into its single child instead of rendering a wrapper.

disabled

Whether interaction is unavailable.

value

Current value exposed by this contract.

AccordionPartProps

as

Element or component rendered for this part.

asChild

Whether to merge this part into its single child instead of rendering a wrapper.

Slots

AccordionRootSlotProps

disabled

Whether interaction is unavailable.

readonly

Whether the value can be inspected but not changed.

value

Current value exposed by this contract.

AccordionItemSlotProps

disabled

Whether interaction is unavailable.

open

Whether the associated popup or disclosure is open.

value

Current value exposed by this contract.

Events

AccordionRoot

update:modelValue

Emitted when the component requests a new controlled value.

Other types

AccordionType

ts
type AccordionType = 'single' | 'multiple'

AccordionValue

ts
type AccordionValue = string | readonly string[]

AccordionValueChangeHandler

ts
type AccordionValueChangeHandler = (value: AccordionValue) => void

Parts

Shared scope: [data-scope="accordion"]. Combine it with a part selector to keep styles local to this component.

PartSelectorRoleExtra 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

KeyBehavior
Enter / SpaceToggle the focused section.
Arrow Up / Arrow DownMove focus between section triggers.
Home / EndMove 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.

Released under the MIT License.