组件
手风琴 Accordion
Accordion:折叠面板。行与行之间有细线,展开内容淡入显示,箭头以回弹曲线切换。部件:Root、Item、ItemTrigger、ItemContent、ItemIndicator。
#基础用法
Interfaces are warm paper, content is ink, hierarchy is light — never pure white, never a hard pop.
Every color, spacing, radius, elevation, and duration resolves from design tokens; a hardcoded pixel is a bug.
Headless machinery owns state, ARIA, and positioning; the style layer dresses the anatomy it renders.
<script setup lang="ts">
import { Accordion } from "@bysages/vue";
const items = [
{
value: "paper",
title: "What is the paper-and-ink system?",
body: "Interfaces are warm paper, content is ink, hierarchy is light — never pure white, never a hard pop.",
},
{
value: "tokens",
title: "Where do visual values come from?",
body: "Every color, spacing, radius, elevation, and duration resolves from design tokens; a hardcoded pixel is a bug.",
},
{
value: "ark",
title: "Who owns the interaction?",
body: "Headless machinery owns state, ARIA, and positioning; the style layer dresses the anatomy it renders.",
},
];
</script>
<template>
<Accordion.Root :default-value="['paper']">
<Accordion.Item v-for="item in items" :key="item.value" :value="item.value">
<Accordion.ItemTrigger>
{{ item.title }}
<Accordion.ItemIndicator>
<svg viewBox="0 0 16 16" fill="none" aria-hidden="true">
<path
d="M4 6l4 4 4-4"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
/>
</svg>
</Accordion.ItemIndicator>
</Accordion.ItemTrigger>
<Accordion.ItemContent>
<p>{{ item.body }}</p>
</Accordion.ItemContent>
</Accordion.Item>
</Accordion.Root>
</template>
#属性
#ItemContent
纯造型的部件——自身没有属性,沿用部件结构的共享样式。
#ItemContext
纯造型的部件——自身没有属性,沿用部件结构的共享样式。
#ItemIndicator
纯造型的部件——自身没有属性,沿用部件结构的共享样式。
#ItemTrigger
纯造型的部件——自身没有属性,沿用部件结构的共享样式。
#Item
| 属性 | 类型 | 默认值 | 描述 |
|---|---|---|---|
disabled | boolean | undefined | 是否禁用手风琴项 | |
value | string | 手风琴项的值 |
#Root
| 属性 | 类型 | 默认值 | 描述 |
|---|---|---|---|
collapsible | boolean | false | 手风琴项展开后能否关闭 |
defaultValue | string[] | 默认展开的手风琴项;无需控制手风琴值时使用 | |
disabled | boolean | 是否禁用手风琴项 | |
id | string | 组件内部状态机的唯一标识 | |
ids | Partial<{ root: string; item(value: string): string; itemContent(value: string): string; itemTrigger(value: string): string; }> | 手风琴内各元素的 id;便于组合使用 | |
modelValue | string[] | 手风琴的 v-model 值 | |
multiple | boolean | false | 是否允许同时展开多个手风琴项 |
orientation | 'horizontal' | 'vertical' | "vertical" | 手风琴项的方向,可为 horizontal 或 vertical |