关于 tailwind-best-practices
面向 Mastra Playground UI 贡献者的样式指南,按优先级规定组件、设计令牌和 Tailwind 类的使用,并提供详细规则参考。
主要功能
- 01覆盖三类样式问题的优先级规则
- 02复用现有设计系统组件的指南
- 03沿用现有设计令牌的规则
- 04限制任意值和 className 覆盖
- 05含示例与评审说明的参考文件
适用场景
- 01为 Playground 编写 React 组件样式
- 02检查 UI 代码的样式一致性
- 03重构已有样式组件
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ mastra-ai/ mastra --skill tailwind-best-practices安装后在 Claude Code 中输入/tailwind-best-practices确认已加载。
包含的文件
除 SKILL.md 外,安装时一起下载的参考资料和脚本。
references/tailwind-best-practices-reference.mdreferences/rules/classname-no-arbitrary.mdclassname-no-ds-override.mdcomponent-use-existing.mdtokens-no-modification.mdtokens-use-existing.md详细介绍
Tailwind 最佳实践
概述
Mastra Playground UI 样式的路由与优先级指南,包含 3 个类别下的 5 条规则。规则文件中包含详细的说明、示例和审查指引,用于确保设计系统的一致性、防止设计令牌漂移,并维护组件库的完整性。
适用范围
packages/playground-uipackages/playground
何时应用
在以下情况下参考这些指南:
- 编写使用 Tailwind 样式的新 React 组件
- 审查代码的样式一致性
- 重构已有的样式组件
- 添加或修改 UI 元素
按优先级排列的指南
规则按影响程度排定优先级:
| 优先级 | 类别 | 影响 |
|---|---|---|
| 1 | 组件使用 | CRITICAL |
| 2 | 设计令牌 | CRITICAL |
| 3 | ClassName 用法 | HIGH |
快速参考
关键模式(优先应用)
组件使用:
- 使用
@playground-ui/ds/components/中的现有组件(component-use-existing) - 切勿在
ds/文件夹中创建新组件
设计令牌:
- 在
@playground-ui中仅使用tailwind.config.ts中的令牌(tokens-use-existing) - 切勿修改设计令牌或
tailwind.config.ts(tokens-no-modification)
高影响模式
ClassName 用法:
- 除
height和width外,不使用任意 Tailwind 值(classname-no-arbitrary) - 在 DS 组件上不使用
className属性,但DialogContent和Popover上的h-/w-除外(classname-no-ds-override)
参考资料
规则文件是详细指南和示例的权威来源:
references/tailwind-best-practices-reference.md- 包含类别顺序和规则文件路径的规则目录references/rules/- 按类别组织的独立规则文件
仅在实现或审查特定样式规则时加载相关规则文件。使用目录来选择合适的规则,无需加载所有示例。
要查找特定模式,请在规则目录中进行搜索:
grep -l "component" references/rules/
grep -l "token" references/rules/
grep -l "className" references/rules/
references/rules/ 中的规则类别
component-*- 组件使用规则(1 条规则)tokens-*- 设计令牌规则(2 条规则)classname-*- ClassName 用法规则(2 条规则)
评论
支持 Markdown