react-bits
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseReact Bits
React Bits
Fetches real, current component source from the React Bits public registry instead of recalling it from training data. React Bits (reactbits.dev, MIT + Commons Clause, by David Haz) publishes 165 animated components — Text Animations, Animations, Components, Backgrounds — each in 4 variants (JS/TS × CSS/Tailwind).
本skill从React Bits公共注册表获取真实、最新的组件源码,而非从训练数据中回忆。React Bits(reactbits.dev,采用MIT + Commons Clause许可证,作者David Haz)发布了165个动画组件——涵盖文字动画、动效、组件、背景四类——每个组件都有4种变体(JS/TS × CSS/Tailwind)。
The hard rule
硬性规则
Never write React Bits component code from memory. Always fetch it live.
Verified failure mode (baseline test, no skill): asked for Aurora + BlurText, an agent hallucinated plausible-looking code, guessed as a dependency (the live package is ), invented prop defaults, and only disclosed the guessing when explicitly asked. The code looked complete and shippable. It wasn't current.
framer-motionmotionTraining data goes stale; this library updates variants in sync. If you can't reach the registry, say so — don't fall back to recalled code.
绝对不要凭记忆编写React Bits组件代码,必须实时拉取。
已验证的失败模式(未使用本skill的基线测试):当被要求提供Aurora + BlurText组件时,Agent会生成看似合理的幻觉代码,猜测依赖为(实际官方包是),凭空编造props默认值,且只有在被明确询问时才会承认是猜测的。这些代码看起来完整可上线,但并不是最新版本。
framer-motionmotion训练数据会过时,而该组件库的变体会同步更新。如果你无法访问注册表,请明确说明——不要退而求其次使用记忆中的代码。
Fetch
拉取方法
bash
node scripts/rb-add.mjs <Component> [<Component>...] --variant <JS|TS>-<CSS|TW> --dest <path> [--install]
node scripts/rb-add.mjs --list # print all 165 namesWrites real source files to (default ) and prints the exact line for that component's dependencies (default variant: ). runs it for you.
--destsrc/componentsnpm installTS-TW--installNo script access? Fetch directly — same registry, same rules:
bash
curl -s https://reactbits.dev/r/<Name>-<JS|TS>-<CSS|TW>.json # one component, files[].content = source
curl -s https://reactbits.dev/r/registry.json # index, 660 entries, no source, no category fieldreactbits.dev is an SPA — an unknown path still returns HTTP 200 with an HTML shell. A 200 status proves nothing; parse the body as JSON and check it before trusting it.
bash
node scripts/rb-add.mjs <Component> [<Component>...] --variant <JS|TS>-<CSS|TW> --dest <path> [--install]
node scripts/rb-add.mjs --list # print all 165 names该命令会将真实源码文件写入指定的路径(默认),并输出该组件依赖对应的准确命令(默认变体为)。加上参数会自动执行安装。
--destsrc/componentsnpm installTS-TW--install无法使用脚本?可以直接拉取——使用同一个注册表,规则不变:
bash
curl -s https://reactbits.dev/r/<Name>-<JS|TS>-<CSS|TW>.json # one component, files[].content = source
curl -s https://reactbits.dev/r/registry.json # index, 660 entries, no source, no category fieldreactbits.dev是一个SPA——即使访问未知路径也会返回HTTP 200状态码和HTML外壳。200状态码不代表请求成功,请将响应体解析为JSON并校验后再使用。
Workflow
工作流程
- Confirm the variant — JS or TS, CSS or Tailwind. Default to matching the project's existing files; ask if genuinely ambiguous.
- Find the component — grep references/catalog.md (offline, 165 entries with category + description + deps) or .
--list - Fetch it with (above). Never hand-write the file.
rb-add.mjs - Read the fetched file's own prop type/interface before wiring it up. Don't guess prop names or defaults even for a component you fetched — read what's actually in the file.
- Install the printed dependencies (or pass ).
--install
- 确认变体类型 —— 选择JS或TS,CSS或Tailwind。默认与项目现有文件保持一致;如果确实不明确,询问用户。
- 查找组件 —— 可以grep搜索references/catalog.md(离线文件,包含165个条目的分类、描述和依赖),或者使用参数。
--list - 拉取组件 —— 使用上述的脚本,绝对不要手动编写组件文件。
rb-add.mjs - 在接入组件前,先阅读拉取到的文件中自带的props类型/接口定义。 即使是你刚拉取的组件,也不要猜测props名称或默认值——请直接读取文件中的实际内容。
- 安装输出的依赖(或者加上参数自动安装)。
--install
Gotchas
注意事项
- Scoped-package deps break naive parsing. 10 components depend on scoped packages, e.g. →
PixelTrail. Splitting a dep string on@react-three/fiber@^9.3.0to get the name yields@for these.""parses correctly (rb-add.mjs); don't reimplement this by hand./^(@[^/]+\/[^@]+|[^@]+)@?(.*)$/ - CSS variants are multi-file. /
JS-CSSship a component file and a siblingTS-CSSfile (both must be written)..css/JS-TWare single-file with Tailwind utility classes.TS-TW - No category field in the registry. has name/title/deps/files only. Category (Text Animations / Animations / Components / Backgrounds) lives only in
registry.json(sourced fromreferences/catalog.md).reactbits.dev/llms.txt - TS projects: some fetched files import types alongside values in one
verbatimModuleSyntaxstatement (e.g.import {...}) — split into a separateimport { motion, Transition } from 'motion/react'if the project's tsconfig hasimport type {...}. This is a mechanical fix, not a reason to rewrite the component.verbatimModuleSyntax: true
- 作用域包依赖会导致简单解析失效。 有10个组件依赖作用域包,例如→
PixelTrail。如果简单地用@react-three/fiber@^9.3.0分割依赖字符串来获取包名,这类依赖的包名会变成空字符串。@中已有正确的解析逻辑(正则为rb-add.mjs),不要手动重新实现。/^(@[^/]+\/[^@]+|[^@]+)@?(.*)$/ - CSS变体是多文件结构。 /
JS-CSS变体包含一个组件文件和一个同级的TS-CSS文件(两者都必须写入)。.css/JS-TW变体是单文件结构,使用Tailwind工具类。TS-TW - 注册表中没有分类字段。 仅包含名称/标题/依赖/文件信息。分类(文字动画/动效/组件/背景)仅存在于
registry.json中(数据来源为references/catalog.md)。reactbits.dev/llms.txt - 开启的TS项目:部分拉取的文件会在同一个
verbatimModuleSyntax语句中同时导入类型和值(例如import {...})——如果项目的tsconfig中设置了import { motion, Transition } from 'motion/react',请将类型导入拆分到单独的verbatimModuleSyntax: true语句中。这是机械性的修复,不需要重写组件。import type {...}
Categories (165 total)
分类(共165个)
Text Animations (32) · Animations (36) · Components (44) · Backgrounds (53). Full list with one-line descriptions and dependencies: references/catalog.md — a GitHub Action regenerates it daily from the live registry, so it stays current without a skill update. Manual refresh: .
node scripts/gen-catalog.mjs文字动画(32个)· 动效(36个)· 组件(44个)· 背景(53个)。包含单行描述和依赖的完整列表见:references/catalog.md——有一个GitHub Action每天会从实时注册表重新生成该文件,因此无需更新skill就能保持内容最新。手动刷新命令:。
node scripts/gen-catalog.mjsAfter installing
安装完成后
For a craft-bar review of the motion you just wired up (easing, duration, frequency-appropriateness, reduced-motion), the upstream repo ships separate skills at (, , , ) — not bundled here, distinct concern (craft review vs. correct fetch/install).
DavidHDev/react-bits/AGENTS/SKILLS/review-animationsimprove-animationsfind-animation-opportunitiesapple-design如果你想对刚接入的动效做工艺级评审(缓动、时长、频率合理性、减少动效适配),上游仓库在路径下提供了独立的skill(、、、)——这些skill未包含在本skill中,属于不同的关注点(工艺评审 vs. 正确拉取/安装)。
DavidHDev/react-bits/AGENTS/SKILLS/review-animationsimprove-animationsfind-animation-opportunitiesapple-design