Skip to content

MotionIcon 动效图标 ​

在指针经过时为图标添加动效。

基础用法 ​

将图标放入默认插槽。开启系统的减少动态效果偏好时,动效会停用。

查看代码收起代码
vue
<script setup lang="ts">
import { ZMotionIcon } from '@codex-proxy/ui'
import { Box, Sparkles } from '@lucide/vue'
</script>

<template>
  <div class="demo-row">
    <ZMotionIcon class="inline-grid size-14 place-items-center rounded-z-lg bg-z-fill-tertiary text-z-primary-text">
      <Box :size="28" />
    </ZMotionIcon>
    <ZMotionIcon variant="brand" class="inline-grid size-14 place-items-center rounded-z-lg bg-z-fill-tertiary text-z-primary-text">
      <Sparkles :size="28" />
    </ZMotionIcon>
    <span>移动指针查看反馈,系统减少动态效果时不播放</span>
  </div>
</template>

MotionIcon API ​

属性 ​

属性说明类型默认值
as根元素标签keyof HTMLElementTagNameMap'span'
variant随机反馈或固定品牌动效'random' | 'brand''random'

插槽 ​

插槽说明
default需要动效的图标内容