css-at-property
它能做什么
这项技能说明如何声明 CSS 自定义属性的类型和初始值,使浏览器能够为它们制作动画。适合制作动态渐变或带类型的设计令牌的前端开发者。
适用场景
- ✓当你希望渐变或颜色变量能平滑地做动画时。
- ✓当自定义属性突然变化,而不是平滑过渡时。
- ✓当你希望设计令牌具有明确定义的类型和作用范围时。
技能链接
https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/css-at-property/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请通过注册颜色变量,让我首页中的渐变能够平滑地做动画。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会为动画或过渡中使用的每个自定义属性添加 @property 声明,包括语法类型(syntax)、初始值(initial-value)以及继承设置(inherits)。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Register CSS custom properties with @property for animation and type safety
CSS custom properties are powerful but limited by default: they are untyped string substitutions that the browser cannot interpolate during transitions or animations. Registering a property with @property gives the browser the information it needs to animate between values, validate token assignments, and scope inheritance — turning custom properties from string macros into first-class typed values. This unlocks gradient animations, typed design tokens, and scoped component theming that are impossible with unregistered properties.
Quick Reference
- Unregistered custom properties cannot be animated — they transition as discrete strings
- @property specifies syntax (color, length, number), initial-value, and inherits
- Registered properties enable smooth interpolation for gradients and complex values
- inherits: false creates scoped tokens that do not cascade to children
Check
Review the CSS custom properties in this file. Identify any properties that are used in transitions or animations — these require @property registration to animate correctly.
Fix
Add @property registrations for the custom properties used in transitions or animations in this CSS. Include the correct syntax descriptor, an initial-value, and the appropriate inherits value.
Explain
Explain how @property works, why unregistered custom properties cannot be animated, what the syntax descriptor values mean, and how inherits controls cascade behaviour.
Code Review
Inspect all CSS transitions and animations that reference custom properties. Flag any custom property used in a transition or animation that is not registered with @property, and flag any @property registration that is missing initial-value.
For full implementation details, code examples, and framework-specific guidance,
see references/rule.md.
Rule page: https://frontendchecklist.io/rules/css/css-at-property
常见问题
为什么普通的自定义属性不能做动画?
这项技能说明,未注册的自定义属性会被当作文字处理,因此浏览器无法在不同值之间进行过渡。
inherits 设为 false 有什么作用?
这项技能说明,它会创建不向子元素传递的限定作用域令牌。
可以为哪些类型的值定义类型?
这项技能举例说明,例如颜色、长度和数字。
详情
作者的原始描述
Use when implementing animated gradients, complex CSS transitions that involve custom property values, or building a typed design token system where custom property misuse should produce visible errors.
热度
- GitHub 星标
- 75k
- 排名
- #2794
- 许可证
- MIT
- 更新时间
- 2026/10/31
评论
- …
同一仓库的更多技能
frontendchecklist
75k使用命令行工具,依据 380 多条关于无障碍、速度、SEO 和安全的规则,检查前端代码和线上页面。
frontend-checklist-global
75k依据全部 386 条 Front-End Checklist 规则审查前端项目,并为发现的每个问题给出具体修复方法。
404-page
75k检查你的页面缺失提示是否提供有用的链接,并返回真正的 404 状态,帮助迷路的访客找到方向。
about-page
75k审查你的网站是否有清晰的关于页面,说明由谁运营,以建立访客和搜索引擎的信任。