Animated CTA Buttons
通过展开箭头、持续按压或滑动手势确认操作。
适用场景
- 当界面需要以下行为时使用 Animated CTA Buttons:通过展开箭头、持续按压或滑动手势确认操作。
安装
选择安装方式,用法示例将同步更新导入路径。
$ bunx --bun shadcn-vue@2.8.2 add https://orvui.efu.me/r/expanding-arrow-button.json https://orvui.efu.me/r/hold-action-button.json https://orvui.efu.me/r/slide-action-button.json
首次使用时,将安装的 src/components/orvui/styles.css 导入项目样式入口。
示例
Expanding Arrow Button
expanding-arrow.vue聚焦或悬停时展开强调色端部,并延伸点状箭头路径。
packages/vue/src/motion/expanding-arrow-button/examples/expanding-arrow.vue
<script setup lang="ts">
import { ExpandingArrowButton } from "@/components/orvui/motion/expanding-arrow-button";
</script>
<template>
<ExpandingArrowButton>Book a demo</ExpandingArrowButton>
</template>
packages/vue/src/motion/expanding-arrow-button/src/ExpandingArrowButton.vue
Hold Action Button
hold-action.vue持续按压直到横向或纵向填充到达终点,提前松开可取消。
packages/vue/src/motion/expanding-arrow-button/examples/hold-action.vue
<script setup lang="ts">
import { onBeforeUnmount, ref } from "vue";
import { HoldActionButton } from "@/components/orvui/motion/expanding-arrow-button";
const visible = ref(false);
let expiry: ReturnType<typeof setTimeout> | undefined;
function feedback() { clearTimeout(expiry); visible.value = true; expiry = setTimeout(() => visible.value = false, 1800); }
onBeforeUnmount(() => clearTimeout(expiry));
</script>
<template>
<div class="flex flex-col items-center justify-center gap-3">
<HoldActionButton @hold-complete="feedback">Hold for vertical fill</HoldActionButton><HoldActionButton type="horizontal" @hold-complete="feedback">Hold for horizontal fill</HoldActionButton>
<p class="h-4 text-xs text-muted-foreground" aria-live="polite">{{ visible ? "Action confirmed" : "Release early to cancel" }}</p>
</div>
</template>
packages/vue/src/motion/expanding-arrow-button/src/HoldActionButton.vue
Slide Action Button
slide-action.vue将手柄拖到终点以确认,未完成的手势会回弹且不提交。
packages/vue/src/motion/expanding-arrow-button/examples/slide-action.vue
<script setup lang="ts">
import { onBeforeUnmount, ref } from "vue";
import { SlideActionButton } from "@/components/orvui/motion/expanding-arrow-button";
const visible = ref(false);
let expiry: ReturnType<typeof setTimeout> | undefined;
function feedback() { clearTimeout(expiry); visible.value = true; expiry = setTimeout(() => visible.value = false, 1800); }
onBeforeUnmount(() => clearTimeout(expiry));
</script>
<template>
<div class="flex flex-col items-center gap-3">
<SlideActionButton complete-label="Ready" @complete="feedback">Slide to continue</SlideActionButton>
<p class="h-4 text-xs text-muted-foreground" aria-live="polite">{{ visible ? "Action completed" : "Drag the arrow to the end" }}</p>
</div>
</template>
packages/vue/src/motion/expanding-arrow-button/src/SlideActionButton.vue
状态与事件
此示例组合没有声明成对的受控属性与 update 事件。使用已列出的属性、原生事件和插槽组合内容;不要为它添加未公开的 v-model。
API 参考
Expanding Arrow Button
disabled?booleanfalseaccentClassName?string—labelClassName?string—插槽
default() => VNodeChild#defaultHold Action Button
type?"vertical" | "horizontal""vertical"holdingLabel?boolean | null | string | number | void | VNode<RendererNode, RendererElement, { [key: string]: any; }> | VNodeArrayChildren | ComponentOptions<any, any, any, ComputedOptions, MethodOptions, any, any, any, string, {}, {}, string, {}, {}, {}, string, ComponentProvideOptions> | FunctionalComponent<any, {}, any, {}> | ComponentPublicInstanceConstructor<any, any, any, any, ComputedOptions, MethodOptions>"Keep holding"completeLabel?boolean | null | string | number | void | VNode<RendererNode, RendererElement, { [key: string]: any; }> | VNodeArrayChildren | ComponentOptions<any, any, any, ComputedOptions, MethodOptions, any, any, any, string, {}, {}, string, {}, {}, {}, string, ComponentProvideOptions> | FunctionalComponent<any, {}, any, {}> | ComponentPublicInstanceConstructor<any, any, any, any, ComputedOptions, MethodOptions>"Done"holdDuration?number1600disabled?booleanfalsefillClassName?string—labelClassName?string—事件
holdComplete—@holdComplete插槽
default() => VNodeChild#defaultholdingLabel() => VNodeChild#holdingLabelcompleteLabel() => VNodeChild#completeLabelSlide Action Button
completeLabel?boolean | null | string | number | void | VNode<RendererNode, RendererElement, { [key: string]: any; }> | VNodeArrayChildren | ComponentOptions<any, any, any, ComputedOptions, MethodOptions, any, any, any, string, {}, {}, string, {}, {}, {}, string, ComponentProvideOptions> | FunctionalComponent<any, {}, any, {}> | ComponentPublicInstanceConstructor<any, any, any, any, ComputedOptions, MethodOptions>"Complete"threshold?number.82resetDelay?number1200thumbClassName?string—fillClassName?string—disabled?booleanfalse事件
complete—@complete插槽
default() => VNodeChild#defaultcompleteLabel() => VNodeChild#completeLabel无障碍
为交互控件提供明确的无障碍名称。保留文档中的键盘路径、可见焦点与减少动态效果状态;自定义插槽应继续保留所替代部件的语义。
常见问题
- 如何配置 Animated CTA Buttons?
- 通过 disabled、accentClassName、labelClassName 配置 Animated CTA Buttons;API 表列出其类型与默认值。
- 如何连接到应用状态?
- 通过default 插槽提供内容,应用副作用由调用方管理。
- 可以在服务端渲染吗?
- 可以在 Vue SSR 应用中正常渲染。服务端与客户端的初始 props 应保持一致;浏览器测量与交互资源在挂载后启动。
更新于
来源与许可 ↗MIT · 0.1.1