@blobatar/vue

中文文档
2.7.0发布于 2026/08/29MITTypeScriptES Module零依赖构建来源已验证近 30 天下载 5480

Vue 3 adapter for blobatar — deterministic geometric avatars.

原始使用文档
文档目录3 节
  1. Following the pointer
  2. Versioning
  3. Coming from blobatar/vue

@blobatar/vue

Vue 3 adapter for blobatar — deterministic geometric avatars generated from any string.

bun add @blobatar/vue blobatar

blobatar is a peer dependency: the adapter carries no renderer of its own.

<script setup lang="ts">
import { Blobatar } from "@blobatar/vue";
</script>

<template>
  <Blobatar :name="user.email" :size="48" />
</template>

Animated blobatars need the stylesheet, and render as inline SVG rather than an <img> — :hover never fires inside an <img>, so the two modes cannot be combined:

<script setup lang="ts">
import "blobatar/motion.css";
</script>

<template>
  <Blobatar :name="user.email" animate="hover" />
</template>

Full option reference lives in the main README.

Following the pointer

The eyes can track the cursor. That layer is the one part of the motion system that needs JavaScript, so it is a separate subpath and costs nothing unless you import it:

<script setup lang="ts">
import { ref } from "vue";
import { Blobatar } from "@blobatar/vue";
import { useGaze } from "@blobatar/vue/gaze";
import "blobatar/motion.css";
import "blobatar/gaze.css"; // required — the eyes hold still without it

const blob = ref();
useGaze(blob, { travel: 3, target: "pointer" });
</script>

<template>
  <Blobatar ref="blob" :name="user.email" animate="always" :size="200" />
</template>

It takes the ref rather than handing one back, because in Vue you already own it. What the ref holds is the component instance rather than an element, and the composable reads $el off it — so the same call works if you put the ref on an <svg> of your own instead.

travel is the excursion, and it is what opts a blobatar into the layer: --mo-track-travel starts at 0px, so a page with the stylesheet loaded and the excursion set nowhere has a driver running and no eyes moving. It is in viewBox units — the blobatar is 100 across, so 3 is 3% of the face — and about 1.5 to 4 reads well. Leave it out and the stylesheet owns it instead, which is the better route for a whole field of blobatars, since the property inherits, or for anything responsive:

.hero .mo-eyes { --mo-track-travel: 3px; }

Pick one, not both. A rule like that one wins over travel, since the option is written inline on the <svg> and reaches the eyes by inheritance.

Everything in the options is read once, when the element arrives. Aiming that changes is lookAt, in a watcher of your own:

const { lookAt } = useGaze(blob, { travel: 3 });
watchEffect(() => lookAt(watching.value ? "pointer" : "rest"));

Both take the same things: a point in client coordinates, an element, "pointer" for the cursor, "rest" to park the eyes in the middle without resuming the idle glance, or null for nothing, which hands it back. The last thing asked for wins, whichever asked, and aiming before the blobatar has mounted is remembered rather than dropped — so a caret can be driven straight through lookAt with no re-render per keystroke.

Versioning

Every package in the set publishes the same version, and the major names the generation — the frozen seed-to-look mapping. @blobatar/vue@2 renders gen2, exactly as blobatar@2 does. Upgrading a major is the opt-in to your users' avatars changing, so the peer range on blobatar is an exact major rather than ^: a mixed pair is not a version skew, it is the wrong picture.

Coming from blobatar/vue

blobatar/vue still exists and still works. This package re-exports it, so the two are the same component rather than two copies and cannot drift. That subpath is deprecated and is removed in v3 — there is no hurry, and no risk in waiting.

bunx blobatar-codemod .
bun add @blobatar/vue

The codemod rewrites every blobatar/vue specifier it finds, in imports, require, dynamic import() and prose, and is safe to run twice. It does not install anything; that command is yours.

版本与发布记录

@blobatar/vue 共发布 7 个版本,首次发布于 2026/08/20;过去 12 个月发布了 7 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
2.7.0latest2026/08/292 个月前
2.6.02026/08/292 个月前
2.5.02026/08/242 个月前
2.4.02026/08/212 个月前
2.3.12026/08/212 个月前
2.3.02026/08/202 个月前

关于 @blobatar/vue 的常见问题

@blobatar/vue 是什么?

Vue 3 adapter for blobatar — deterministic geometric avatars.

如何安装 @blobatar/vue?

在项目目录运行 npm install @blobatar/vue,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:blobatar(2.x)、vue(>=3)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@blobatar/vue 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@blobatar/vue 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@blobatar/vue 可以商用吗?

@blobatar/vue 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@blobatar/vue 的下载量有多少?

根据 npm 官方下载统计,@blobatar/vue 在 2026/10/09 – 2026/11/07 这 30 天内被下载 5,480 次,日均约 183 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@blobatar/vue 还在维护吗?

最新版本 2.7.0 发布于 2026/08/29(2 个月前);至今共发布 7 个版本,其中过去 12 个月发布了 7 个;首次发布于 2026/08/20。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。