Action Swap

使用模糊、滚动或错开过渡替换简短操作文字与图标。

适用场景

  • 当界面需要以下行为时使用 Action Swap:使用模糊、滚动或错开过渡替换简短操作文字与图标。

安装

选择安装方式,用法示例将同步更新导入路径。

$ bunx --bun shadcn-vue@2.8.2 add https://orvui.efu.me/r/action-swap.json https://orvui.efu.me/r/action-swap-cascade.json https://orvui.efu.me/r/action-swap-blur.json https://orvui.efu.me/r/action-swap-roll.json

此示例还需要:

终端

首次使用时,将安装的 src/components/orvui/styles.css 导入项目样式入口。

示例

逐字

cascade.vue

让旧标签字符离开,再逐字带入替换内容。

模糊

blur.vue

使用短暂模糊和缩放过渡交叉切换操作内容。

滚动

roll.vue

让下一段标签或图标从下方向上进入原有空间。

状态与事件

需要由表单、路由或父组件管理时,绑定下列状态并接收对应更新。v-model 是属性与 update 事件的简写;值的类型应与 API 一致。

组件状态绑定
组件Vue 绑定更新事件
ActionSwapButtonv-modelstringupdate:modelValue
ActionSwapButtonv-model:valuestringupdate:value
ActionSwapCascadeButtonv-modelstringupdate:modelValue
ActionSwapCascadeButtonv-model:valuestringupdate:value
ActionSwapBlurButtonv-modelstringupdate:modelValue
ActionSwapBlurButtonv-model:valuestringupdate:value
ActionSwapRollButtonv-modelstringupdate:modelValue
ActionSwapRollButtonv-model:valuestringupdate:value

可选受控属性未传入时,按组件文档的默认行为工作;不要用固定的 false 或空值代替未传入。异步请求和持久化在应用中处理,再把结果传回组件。

API 参考

逐字

ActionSwapCascadeButton

items
{ id: string; label: VNodeChild | Component; icon?: VNodeChild | Component; ariaLabel?: string; }[]
—
modelValue?
string
—
value?
string
—
defaultValue?
string
—
cycle?
boolean
undefined
disabled?
boolean
false
variant?
"primary" | "secondary" | "ghost" | "outline"
—
size?
"sm" | "md" | "lg" | "icon"
—

事件

update:modelValue
—
@update:modelValue
update:value
—
@update:value
valueChange
—
@valueChange

插槽

default
—

作用域参数: v-bind

#default
icon
—

作用域参数: v-bind

#icon

ActionSwapButton

items
{ id: string; label: VNodeChild | Component; icon?: VNodeChild | Component; ariaLabel?: string; }[]
—
modelValue?
string
—
value?
string
value.value
defaultValue?
string
props.items[0]?.id
animation?
"blur" | "cascade" | "roll"
"blur"
variant?
"primary" | "secondary" | "ghost" | "outline"
"secondary"
size?
"sm" | "md" | "lg" | "icon"
"md"
iconOnly?
boolean
undefined
cycle?
boolean
true
disabled?
boolean
false

事件

update:modelValue
—
@update:modelValue
change
—
@change
update:value
—
@update:value
valueChange
—
@valueChange
click
—
@click

插槽

icon
—

作用域参数: item

#icon
default
—

作用域参数: item

#default

ActionSwapIcon

value
string | number
—
animation?
"blur" | "cascade" | "roll"
"blur"

插槽

default
() => VNodeChild
#default

ActionSwapText

value
string | number
—
animation?
"blur" | "cascade" | "roll"
"blur"

插槽

default
() => VNodeChild
#default

模糊

ActionSwapBlurButton

items
{ id: string; label: VNodeChild | Component; icon?: VNodeChild | Component; ariaLabel?: string; }[]
—
modelValue?
string
—
value?
string
—
defaultValue?
string
—
cycle?
boolean
undefined
disabled?
boolean
false
variant?
"primary" | "secondary" | "ghost" | "outline"
—
size?
"sm" | "md" | "lg" | "icon"
—

事件

update:modelValue
—
@update:modelValue
update:value
—
@update:value
valueChange
—
@valueChange

插槽

default
—

作用域参数: v-bind

#default
icon
—

作用域参数: v-bind

#icon

ActionSwapButton

items
{ id: string; label: VNodeChild | Component; icon?: VNodeChild | Component; ariaLabel?: string; }[]
—
modelValue?
string
—
value?
string
value.value
defaultValue?
string
props.items[0]?.id
animation?
"blur" | "cascade" | "roll"
"blur"
variant?
"primary" | "secondary" | "ghost" | "outline"
"secondary"
size?
"sm" | "md" | "lg" | "icon"
"md"
iconOnly?
boolean
undefined
cycle?
boolean
true
disabled?
boolean
false

事件

update:modelValue
—
@update:modelValue
change
—
@change
update:value
—
@update:value
valueChange
—
@valueChange
click
—
@click

插槽

icon
—

作用域参数: item

#icon
default
—

作用域参数: item

#default

ActionSwapIcon

value
string | number
—
animation?
"blur" | "cascade" | "roll"
"blur"

插槽

default
() => VNodeChild
#default

ActionSwapText

value
string | number
—
animation?
"blur" | "cascade" | "roll"
"blur"

插槽

default
() => VNodeChild
#default

滚动

ActionSwapRollButton

items
{ id: string; label: VNodeChild | Component; icon?: VNodeChild | Component; ariaLabel?: string; }[]
—
modelValue?
string
—
value?
string
—
defaultValue?
string
—
cycle?
boolean
undefined
disabled?
boolean
false
variant?
"primary" | "secondary" | "ghost" | "outline"
—
size?
"sm" | "md" | "lg" | "icon"
—

事件

update:modelValue
—
@update:modelValue
update:value
—
@update:value
valueChange
—
@valueChange

插槽

default
—

作用域参数: v-bind

#default
icon
—

作用域参数: v-bind

#icon

ActionSwapButton

items
{ id: string; label: VNodeChild | Component; icon?: VNodeChild | Component; ariaLabel?: string; }[]
—
modelValue?
string
—
value?
string
value.value
defaultValue?
string
props.items[0]?.id
animation?
"blur" | "cascade" | "roll"
"blur"
variant?
"primary" | "secondary" | "ghost" | "outline"
"secondary"
size?
"sm" | "md" | "lg" | "icon"
"md"
iconOnly?
boolean
undefined
cycle?
boolean
true
disabled?
boolean
false

事件

update:modelValue
—
@update:modelValue
change
—
@change
update:value
—
@update:value
valueChange
—
@valueChange
click
—
@click

插槽

icon
—

作用域参数: item

#icon
default
—

作用域参数: item

#default

ActionSwapIcon

value
string | number
—
animation?
"blur" | "cascade" | "roll"
"blur"

插槽

default
() => VNodeChild
#default

ActionSwapText

value
string | number
—
animation?
"blur" | "cascade" | "roll"
"blur"

插槽

default
() => VNodeChild
#default

无障碍

为交互控件提供明确的无障碍名称。保留文档中的键盘路径、可见焦点与减少动态效果状态;自定义插槽应继续保留所替代部件的语义。

常见问题

如何配置 Action Swap?
通过 items、modelValue、value、defaultValue、animation、variant、size、iconOnly、cycle、disabled 配置 Action Swap;API 表列出其类型与默认值。
如何连接到应用状态?
监听 update:modelValue、change、update:value、valueChange、click,将组件连接到应用状态。
可以在服务端渲染吗?
可以在 Vue SSR 应用中正常渲染。服务端与客户端的初始 props 应保持一致;浏览器测量与交互资源在挂载后启动。

更新于