Arc Picker
通过手势或键盘让弧形标签列表穿过固定选择点。
适用场景
- 当界面需要以下行为时使用 Arc Picker:通过手势或键盘让弧形标签列表穿过固定选择点。
安装
选择安装方式,用法示例将同步更新导入路径。
$ bunx --bun shadcn-vue@2.8.2 add https://orvui.efu.me/r/arc-picker.json https://orvui.efu.me/r/button.json
首次使用时,将安装的 src/components/orvui/styles.css 导入项目样式入口。
示例
预览
Drag vertically or scroll to choose. Use arrow keys to move, Home and End to jump.
Drag vertically, scroll or use the arrow keys.
packages/vue/src/motion/arc-picker/demo.vue
<script setup lang="ts">
import { ref } from "vue";
import { ArcPicker, type ArcPickerSide } from "@/components/orvui/motion/arc-picker";
import { Button } from "@/components/orvui/motion/button";
const directions = ["top", "bottom", "left", "right"] as const;
const times = ["First light", "Dawn", "Daybreak", "Sunrise", "Early morning", "Morning", "Late morning", "Midday", "Noon", "Afternoon", "Golden hour", "Sunset", "Blue hour", "Dusk", "Twilight", "Evening", "Nightfall", "Night", "Late night", "Midnight", "Deep night", "Starlight"];
const options = times.map(label => ({ label, value: label.toLowerCase().replaceAll(" ", "-") }));
const value = ref("golden-hour");
const side = ref<ArcPickerSide>("right");
</script>
<template><div class="w-full max-w-xl py-5"><fieldset class="flex flex-wrap items-center justify-center gap-1 px-4"><legend class="sr-only">Curve side</legend><Button v-for="direction in directions" :key="direction" size="sm" :variant="side === direction ? 'secondary' : 'ghost'" :aria-pressed="side === direction" @click="side = direction" class="capitalize">{{ direction }}</Button></fieldset><div class="my-8 flex min-h-108 items-center sm:my-10"><ArcPicker v-model="value" :options="options" aria-label="Time of day" :side="side" :radius="260" :visible-count="9" :item-height="48" /></div><p class="px-6 text-center text-xs text-muted-foreground">Drag {{ side === 'top' || side === 'bottom' ? 'horizontally' : 'vertically' }}, scroll or use the arrow keys.</p></div></template>
packages/vue/src/motion/arc-picker/src/ArcPicker.vue
状态与事件
需要由表单、路由或父组件管理时,绑定下列状态并接收对应更新。v-model 是属性与 update 事件的简写;值的类型应与 API 一致。
| 组件 | Vue 绑定 | 更新事件 |
|---|---|---|
ArcPicker | v-modelstring | update:modelValue |
可选受控属性未传入时,按组件文档的默认行为工作;不要用固定的 false 或空值代替未传入。异步请求和持久化在应用中处理,再把结果传回组件。
API 参考
optionsreadonly ArcPickerOption[]—modelValue?string—defaultValue?stringprops.options.find(option => !option.disabled)?.valueside?"top" | "bottom" | "left" | "right""right"radius?number280itemHeight?number48visibleCount?number7disabled?booleanfalsename?string—ariaLabel?string"Choose an option"ariaDescribedby?string—事件
update:modelValue—@update:modelValuechange—@change无障碍
为交互控件提供明确的无障碍名称。保留文档中的键盘路径、可见焦点与减少动态效果状态;自定义插槽应继续保留所替代部件的语义。
常见问题
- 如何配置 Arc Picker?
- 通过 options、modelValue、defaultValue、side、radius、itemHeight、visibleCount、disabled、name、ariaLabel、ariaDescribedby 配置 Arc Picker;API 表列出其类型与默认值。
- 如何连接到应用状态?
- 监听 update:modelValue、change,将组件连接到应用状态。
- 可以在服务端渲染吗?
- 可以在 Vue SSR 应用中正常渲染。服务端与客户端的初始 props 应保持一致;浏览器测量与交互资源在挂载后启动。
更新于
来源与许可 ↗MIT · 0.1.1