组件
折叠面板 Collapsible
Collapsible:折叠面板。触发器落在纸面上,面板按状态机测得的高度淡入展开。部件:Root、Trigger、Content、Indicator。
#基础用法
A named visual decision — a color, a spacing step, a radius — compiled into a CSS custom property. Components resolve their every value from tokens, so themes change without restyling.
<script setup lang="ts">
import { Collapsible } from "@bysages/vue";
</script>
<template>
<Collapsible.Root class="w-full">
<Collapsible.Trigger>
What is a design token?
<Collapsible.Indicator>
<svg viewBox="0 0 16 16" fill="none" aria-hidden="true">
<path
d="M6 4l4 4-4 4"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
/>
</svg>
</Collapsible.Indicator>
</Collapsible.Trigger>
<Collapsible.Content>
<p>
A named visual decision — a color, a spacing step, a radius — compiled into a CSS custom
property. Components resolve their every value from tokens, so themes change without
restyling.
</p>
</Collapsible.Content>
</Collapsible.Root>
</template>
#属性
#Content
纯造型的部件——自身没有属性,沿用部件结构的共享样式。
#Indicator
纯造型的部件——自身没有属性,沿用部件结构的共享样式。
#Root
| 属性 | 类型 | 默认值 | 描述 |
|---|---|---|---|
collapsedHeight | number | string | 内容折叠后的高度 | |
collapsedWidth | number | string | 内容折叠后的宽度 | |
defaultOpen | boolean | 折叠组件初始是否展开;无需控制展开状态时使用 | |
disabled | boolean | 折叠组件是否禁用 | |
id | string | 组件内部状态机的唯一标识 | |
ids | Partial<{ root: string; content: string; trigger: string; }> | 折叠组件内各元素的 id;便于组合使用 | |
lazyMount | boolean | false | 是否延迟挂载 |
open | boolean | 折叠组件的受控展开状态 | |
unmountOnExit | boolean | false | 离场时是否卸载 |
#Trigger
纯造型的部件——自身没有属性,沿用部件结构的共享样式。