Reaction (点赞)
点赞 / 表态(v-model + 计数),紧凑胶囊,带填充变色、弹跳、爆裂光环与数字滚动动画。
基础用法
紧凑胶囊,而非带文字内距的实心按钮——点击切换、图标填充变色 + 弹跳 + 爆裂,计数随之滚动。
Basic.vue
带文字 label
默认插槽 = 可见文字,渲染在按钮**内部**——所以点图标、文字或计数任意处都触发(收藏游戏 / 收藏资源 这类场景);文字随激活态变色。不传则保持紧凑的「图标 + 计数」。
Labeled.vue
不同表态
Variants.vue
尺寸
Sizes.vue
纯切换(无计数)
ToggleOnly.vue
操作栏(toggle / action)
点赞是切换(默认);评论 / 转发 / 更多用 :toggle="false" 做成「动作」—— 无按下态、无爆裂,只有轻点反馈,用原生 @click 处理。整条栏风格统一, 不必混入更重的图标按钮。
ActionRow.vue
自定义(插槽 + 任意颜色)
#icon 插槽接管字形(emoji / 图片 / SVG,可按 active 切换); color 也接受任意 CSS 颜色(品牌色)——填充、弹跳、爆裂全跟着它走。
Custom.vue
属性
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| color | KunUIColor | (string & {}) | "danger" | Active (liked) colour — a palette key OR any CSS colour string (e.g. a brand `#ff6a00`). The icon fill, pop and burst all follow it. Default `danger`. |
| count | number | undefined | |
| disableAnimation | boolean | false | Disable the pop / burst / count-roll animations (also off under reduced-motion). |
| disabled | boolean | false | |
| icon | string | "lucide:heart" | Icon name (default a heart); filled + coloured when active. Override the whole glyph (emoji / image / per-state) with the `#icon` slot instead. |
| label | string | "点赞" | Accessible label base; the count is appended for the full name. Default `点赞`. |
| modelValue | boolean | false | |
| size | "sm" | "md" | "lg" | "md" | |
| toggle | boolean | true | `true` (default) = a like/press TOGGLE: pressed state (`aria-pressed`), icon fill + colour, and a celebratory burst. `false` = a one-shot ACTION (share / more …) in the same compact skin — no self-toggle, no burst, just a tactile pop; handle the click with a native `@click`. Lets a whole reactions row use one component instead of mixing in a heavier icon button. In BOTH modes the filled/coloured skin follows the `active` model. So an action-mode reaction can be a controlled "menu button": wrap it as a `KunPopover` trigger, bind `:model-value` to your own state (e.g. 收藏 = "in ≥1 list"), and the click opens the picker instead of self-toggling. |