Accordion
A collapsible panel list suitable for displaying FAQ sections, detailed terms, or step-by-step information. Built on Radix Vue headless primitives, it supports multiple neo-brutalist visual variants.
Demo
默认
扁平
幽灵
交互(interactive)
Installation
pnpm dlx brutx-vue@latest add accordionUsage
<script setup>
import { Accordion, AccordionItem, AccordionTrigger, AccordionContent } from 'brutx-ui-vue'
</script>
<template>
<Accordion type="single" collapsible>
<AccordionItem value="item-1">
<AccordionTrigger>Panel Title 1</AccordionTrigger>
<AccordionContent>
Accordion content 1 goes here.
</AccordionContent>
</AccordionItem>
<AccordionItem value="item-2">
<AccordionTrigger>Panel Title 2</AccordionTrigger>
<AccordionContent>
Accordion content 2 goes here.
</AccordionContent>
</AccordionItem>
</Accordion>
</template>Variants
Use the variant prop on AccordionItem to set different neo-brutalist styles:
| Variant | Description |
|---|---|
default | Default with thick black border and solid shadow offset at the bottom-right |
flat | Thick black border only, no shadow effects |
ghost | Transparent background, no border or shadow, minimal presentation |
interactive | Enhanced shadow and highlight on hover while the header and panel stay in place |
<template>
<AccordionItem value="item" variant="interactive">
<AccordionTrigger>Interactive Accordion Item</AccordionTrigger>
<AccordionContent>Hover enhances the shadow; the header stays in place when expanded.</AccordionContent>
</AccordionItem>
</template>Content Area Styling
AccordionContent styling automatically inherits the variant of its parent AccordionItem (synchronized via provide/inject, no manual specification needed). The separator line is activated at the bottom of AccordionTrigger upon expand, allowing the content panel to focus on padding and secondary background hierarchy:
| Variant | Content Area Styling | Visual Effect |
|---|---|---|
default | bg-brutal-muted | Secondary muted background creating depth against the collapsed state |
flat | bg-brutal-muted/30 | Gentle semi-transparent muted tone, echoing the flat design |
ghost | Transparent background | Clean transparent background, lightweight and minimal |
interactive | bg-brutal-muted hover:bg-brutal-muted/20 | Secondary background with subtle hover highlight |
Note: The variant applies across all three layers --
AccordionItem(container),AccordionTrigger(trigger), andAccordionContent(content area) -- to maintain visual consistency.
Sub-components
| Component | Description |
|---|---|
Accordion | Root container, manages expand state and mode |
AccordionItem | Single panel item, contains trigger and content |
AccordionTrigger | Panel trigger, click to toggle expand/collapse |
AccordionContent | Panel content area, shown when expanded |
API Reference
Accordion
| Name | Type | Default | Description |
|---|---|---|---|
collapsible | boolean | undefined | —Runtime fallback: | In single mode, allows activating the open item again to close all content. It has no effect in multiple mode. |
DetailsDeclared typeboolean | undefined Literal values
Default value details
Sourcepackages/ui/src/components/accordion/Accordion.vue | |||
disabled | boolean | undefined | —Runtime fallback: | Disables interaction with the entire accordion and all its items. |
DetailsDeclared typeboolean | undefined Literal values
Default value details
Sourcepackages/ui/src/components/accordion/Accordion.vue | |||
dir | Direction | undefined | —Runtime fallback: | The reading direction of the accordion, used for keyboard navigation. |
DetailsDeclared typeDirection | undefined Literal values
Default value details
Sourcepackages/ui/src/components/accordion/Accordion.vue | |||
orientation | DataOrientation | undefined | —Runtime fallback: | The accordion orientation used for layout state and arrow-key navigation. |
DetailsDeclared typeDataOrientation | undefined Literal values
Default value details
Sourcepackages/ui/src/components/accordion/Accordion.vue | |||
unmountOnHide | boolean | undefined | —Runtime fallback: | Controls whether closed content is unmounted; an item can override it with its own unmountOnHide prop. |
DetailsDeclared typeboolean | undefined Literal values
Default value details
Sourcepackages/ui/src/components/accordion/Accordion.vue | |||
asChild | boolean | undefined | — | Merges the root primitive props and behavior into its child element. |
DetailsDeclared typeboolean | undefined Literal values
Default value details
Sourcepackages/ui/src/components/accordion/Accordion.vue | |||
as | AsTag | Component | undefined | — | The element or component rendered by the root primitive; asChild delegates rendering to the child. |
DetailsDeclared typeAsTag | Component | undefined Literal values
Default value details
Sourcepackages/ui/src/components/accordion/Accordion.vue | |||
type | SingleOrMultipleType | undefined | — | Selects single or multiple expansion, overriding the mode inferred from modelValue or defaultValue. |
DetailsDeclared typeSingleOrMultipleType | undefined Literal values
Default value details
Sourcepackages/ui/src/components/accordion/Accordion.vue | |||
modelValue | string | string[] | undefined | — | The controlled expanded value: a string for single mode or a string array for multiple mode. Supports v-model. |
DetailsDeclared typestring | string[] | undefined Default value details
Sourcepackages/ui/src/components/accordion/Accordion.vue | |||
defaultValue | string | string[] | undefined | — | The initially expanded value in uncontrolled mode. |
DetailsDeclared typestring | string[] | undefined Default value details
Sourcepackages/ui/src/components/accordion/Accordion.vue | |||
class | string | undefined | — | Custom CSS classes merged onto the accordion root element. |
DetailsDeclared typestring | undefined Default value details
Sourcepackages/ui/src/components/accordion/Accordion.vue | |||
| Name | Signature or type | Description |
|---|---|---|
@update:modelValue | [value: string | string[] | undefined] | Emits the new expanded value to synchronize single or multiple state through v-model. |
DetailsDeclared type[value: string | string[] | undefined] Sourcepackages/ui/src/components/accordion/Accordion.vue | ||
| Name | Signature or type | Description |
|---|---|---|
#default | {} | The accordion items, typically AccordionItem components. This wrapper does not forward the underlying primitive slot arguments. |
DetailsDeclared type{}Sourcepackages/ui/src/components/accordion/Accordion.vue | ||
AccordionContent
| Name | Type | Default | Description |
|---|---|---|---|
forceMount | boolean | undefined | — | Forces content mounting so an external animation library can control its visibility transitions. |
DetailsDeclared typeboolean | undefined Literal values
Default value details
Sourcepackages/ui/src/components/accordion/AccordionContent.vue | |||
asChild | boolean | undefined | — | Merges the content primitive props and behavior into the inner content container. |
DetailsDeclared typeboolean | undefined Literal values
Default value details
Sourcepackages/ui/src/components/accordion/AccordionContent.vue | |||
as | AsTag | Component | undefined | — | The element or component rendered by the collapsible content primitive. |
DetailsDeclared typeAsTag | Component | undefined Literal values
Default value details
Sourcepackages/ui/src/components/accordion/AccordionContent.vue | |||
class | string | undefined | — | Classes merged onto the outer element that handles collapse animation. The inner container inherits its visual variant from AccordionItem. |
DetailsDeclared typestring | undefined Default value details
Sourcepackages/ui/src/components/accordion/AccordionContent.vue | |||
| Name | Signature or type | Description |
|---|---|---|
#default | {} | The body content displayed when the panel is expanded. |
DetailsDeclared type{}Sourcepackages/ui/src/components/accordion/AccordionContent.vue | ||
AccordionItem
| Name | Type | Default | Description |
|---|---|---|---|
variant | "default" | "flat" | "ghost" | "interactive" | undefined | "default" | The item visual variant, also provided to its trigger and content area. |
DetailsDeclared typeNonNullable<"flat" | "default" | "ghost" | "interactive" | null | undefined> | undefined Literal values
Default value details
Sourcepackages/ui/src/components/accordion/AccordionItem.vue | |||
class | string | undefined | undefined | Custom CSS classes merged onto the accordion item root. |
DetailsDeclared typestring | undefined Default value details
Sourcepackages/ui/src/components/accordion/AccordionItem.vue | |||
disabled | boolean | undefined | — | Disables this item. It is also disabled whenever the root Accordion is disabled. |
DetailsDeclared typeboolean | undefined Literal values
Default value details
Sourcepackages/ui/src/components/accordion/AccordionItem.vue | |||
valueRequired | string | — | The item string identifier, which must be unique within its Accordion. |
DetailsDeclared typestring Default value details
Sourcepackages/ui/src/components/accordion/AccordionItem.vue | |||
unmountOnHide | boolean | undefined | —Runtime fallback: | Controls whether this item content is unmounted when closed. |
DetailsDeclared typeboolean | undefined Literal values
Default value details
Sourcepackages/ui/src/components/accordion/AccordionItem.vue | |||
asChild | boolean | undefined | — | Merges the item primitive props and behavior into its child element. |
DetailsDeclared typeboolean | undefined Literal values
Default value details
Sourcepackages/ui/src/components/accordion/AccordionItem.vue | |||
as | AsTag | Component | undefined | — | The element or component rendered by the item root primitive. |
DetailsDeclared typeAsTag | Component | undefined Literal values
Default value details
Sourcepackages/ui/src/components/accordion/AccordionItem.vue | |||
| Name | Signature or type | Description |
|---|---|---|
#default | {} | The item trigger and content, typically AccordionTrigger and AccordionContent. No scope arguments are provided. |
DetailsDeclared type{}Sourcepackages/ui/src/components/accordion/AccordionItem.vue | ||
AccordionTrigger
| Name | Type | Default | Description |
|---|---|---|---|
asChild | boolean | undefined | — | Merges the trigger primitive props and behavior into its child; preserve focusable trigger semantics when composing it. |
DetailsDeclared typeboolean | undefined Literal values
Default value details
Sourcepackages/ui/src/components/accordion/AccordionTrigger.vue | |||
as | AsTag | Component | undefined | — | The element or component rendered by the trigger primitive. |
DetailsDeclared typeAsTag | Component | undefined Literal values
Default value details
Sourcepackages/ui/src/components/accordion/AccordionTrigger.vue | |||
class | string | undefined | undefined | Custom CSS classes merged onto the trigger element, rather than its surrounding heading. |
DetailsDeclared typestring | undefined Default value details
Sourcepackages/ui/src/components/accordion/AccordionTrigger.vue | |||
iconSize | IconSize | undefined | "lg" | The size of the built-in ChevronDown icon. A custom icon slot controls its own icon size. |
DetailsDeclared typeIconSize | undefined Literal values
Referenced types IconSize Type definition — IconSizeexport type IconSize = NonNullable<VariantProps<typeof iconSizeVariants>['size']> Default value details
Sourcepackages/ui/src/components/accordion/AccordionTrigger.vue | |||
| Name | Signature or type | Description |
|---|---|---|
#default | {} | The heading text or content inside the trigger. |
DetailsDeclared type{}Sourcepackages/ui/src/components/accordion/AccordionTrigger.vue | ||
#icon | {} | Replaces the expansion icon, which defaults to ChevronDown. Its container inherits variant styles and rotates when expanded. An explicitly empty slot hides the icon container. |
DetailsDeclared type{}Sourcepackages/ui/src/components/accordion/AccordionTrigger.vue | ||
Accessibility
- Keyboard operation: Supports
Space/Enterto trigger expand/collapse, arrow keys to navigate between panels - ARIA attributes: Automatically manages
aria-expanded,aria-controls,role="region", etc. - Focus management: Tab key focuses the trigger, focus order matches panel order