Bouncy Accordion
在单项展开的分组中打开内容区,布局通过弹簧连续移动。
适用场景
- 当界面需要以下行为时使用 Bouncy Accordion:在单项展开的分组中打开内容区,布局通过弹簧连续移动。
安装
选择安装方式,用法示例将同步更新导入路径。
$ bunx --bun shadcn-vue@2.8.2 add https://orvui.efu.me/r/bouncy-accordion.json
首次使用时,将安装的 src/components/orvui/styles.css 导入项目样式入口。
示例
预览
Coordinate announcements, staging reviews, reminders and quiet hours on a shared timeline.
packages/vue/src/motion/bouncy-accordion/demo.vue
<script setup lang="ts">
import { h } from "vue";
import { CalendarClock, FileText, FolderKanban, PackageCheck, RadioTower, ShieldCheck } from "lucide-vue-next";
import { BouncyAccordion } from "@/components/orvui/motion/bouncy-accordion";
const records = [
["brief", "Release Brief", "Gather launch notes, accountable owners and known risks into a brief handoff before the release.", FileText],
["launch", "Launch Checklist", "Review copy, links, analytics, recovery steps and approvals together before the launch starts.", ShieldCheck],
["campaign", "Campaign Notes", "Attach notes for each channel while keeping the closed task list compact and easy to scan.", RadioTower],
["calendar", "Rollout Calendar", "Coordinate announcements, staging reviews, reminders and quiet hours on a shared timeline.", CalendarClock],
["ship", "Ship Build", "Follow the build artifact, deployment state and final review before completing the release.", PackageCheck],
["archive", "Archive Assets", "File the approved copy, graphics and source in the campaign folder after the rollout ends.", FolderKanban],
] as const;
const items = records.map(([id, title, description, icon]) => ({ id, title, description, icon: h(icon, { class: "h-4 w-4" }) }));
</script>
<template><div class="flex min-h-96 w-full items-center justify-center"><div class="w-full max-w-sm h-[480px]"><BouncyAccordion :items="items" default-value="calendar" /></div></div></template>
packages/vue/src/motion/bouncy-accordion/src/BouncyAccordion.vue
状态与事件
需要由表单、路由或父组件管理时,绑定下列状态并接收对应更新。v-model 是属性与 update 事件的简写;值的类型应与 API 一致。
| 组件 | Vue 绑定 | 更新事件 |
|---|---|---|
BouncyAccordion | v-modelnull | string | update:modelValue |
可选受控属性未传入时,按组件文档的默认行为工作;不要用固定的 false 或空值代替未传入。异步请求和持久化在应用中处理,再把结果传回组件。
API 参考
items{ id: string; title: any; description?: any; icon?: any; disabled?: boolean; }[]—modelValue?null | string—defaultValue?null | stringnullcollapsible?booleantrueclassNames?Record<string, string>—事件
update:modelValue—@update:modelValuechange—@change插槽
title—作用域参数: v-bind
#titlecontent—作用域参数: v-bind
#content无障碍
为交互控件提供明确的无障碍名称。保留文档中的键盘路径、可见焦点与减少动态效果状态;自定义插槽应继续保留所替代部件的语义。
常见问题
- 如何配置 Bouncy Accordion?
- 通过 items、modelValue、defaultValue、collapsible、classNames 配置 Bouncy Accordion;API 表列出其类型与默认值。
- 如何连接到应用状态?
- 监听 update:modelValue、change,将组件连接到应用状态。
- 可以在服务端渲染吗?
- 可以在 Vue SSR 应用中正常渲染。服务端与客户端的初始 props 应保持一致;浏览器测量与交互资源在挂载后启动。
更新于
来源与许可 ↗MIT · 0.1.1