tailwindcss
它能做什么
这个技能指导 Tailwind CSS 的使用。它是一种以工具类为核心的网页样式工具。适合希望用较少的自定义 CSS,就能获得一致间距和排版的界面开发者。
适用场景
- ✓当你在构建网页界面,希望用工具类快速获得一致的样式时。
- ✓当你在 Tailwind 项目中需要响应式布局、悬停状态或深色模式时。
- ✓当你的 Tailwind 类在正式环境中丢失,需要找出原因时。
技能链接
https://github.com/MengTo/Skills/blob/main/agent-skills/web-design/tailwindcss/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“你能用 Tailwind 为这个登录表单设置样式吗?要让它在手机上显示整洁,并支持深色模式。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会直接在标记中添加工具类,使用响应式前缀、状态变体和深色模式设置。对于重复出现的模式,它建议先将其整理为组件,再使用少量可复用的样式规则。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Tailwind CSS — Utility-first Styling Skill
When to use
- Rapid UI building with consistent spacing/typography scales
- Design systems where composition beats bespoke CSS
- Component-driven apps (React/Vue/Svelte), marketing pages, prototypes → production
Key concepts & patterns
- Utilities compose in HTML/JSX:
class="flex gap-4 p-6 bg-zinc-950 text-white" - Responsive variants:
sm: md: lg: xl:etc. - State variants:
hover:,focus:,active:,disabled:,group-hover:,peer-checked: - Arbitrary values (use sparingly):
w-[42rem],bg-[#0b1220],translate-y-[3px] - Dark mode patterns:
dark:with class-based strategy - Extracting repeated patterns:
- Prefer components (JSX/Vue components) first
- Then
@applyfor small reusable patterns (avoid overuse)
- Build pipeline:
- Tailwind scans “content” files for class names and generates CSS (zero-runtime)
Common pitfalls
- Classes not generated in production
- Ensure content paths include all templates/components.
- Avoid building class names dynamically (e.g.
"text-" + color) unless safelisted.
- Overusing
@applyand losing the utility-first benefits - Conflicting styles due to class order assumptions
- Huge HTML class lists with no structure
- Use component composition; break into subcomponents; use
clsx/cvawhen needed.
- Use component composition; break into subcomponents; use
Quick recipes
1) A clean CTA button
<button class="inline-flex items-center justify-center rounded-xl px-5 py-3
bg-indigo-600 text-white font-medium
hover:bg-indigo-500 active:bg-indigo-700
focus:outline-none focus:ring-2 focus:ring-indigo-400/60">
Get started
</button>
2) Responsive hero layout
<section class="mx-auto max-w-6xl px-6 py-16">
<div class="grid gap-10 lg:grid-cols-2 lg:items-center">
<div>
<h1 class="text-4xl font-semibold tracking-tight sm:text-5xl">
Ship a beautiful site fast.
</h1>
<p class="mt-4 text-zinc-600">
Tailwind helps you move quickly without fighting CSS.
</p>
</div>
<div class="rounded-2xl border border-zinc-200 bg-white p-6 shadow-sm">
<!-- media -->
</div>
</div>
</section>
3) Handling dynamic classnames safely
Prefer mapping:
const toneClass = {
success: "bg-emerald-600",
danger: "bg-rose-600",
info: "bg-sky-600",
}[tone];
What to ask the user
- Framework/build tool (Next/Vite/Remix/Webflow export)?
- Do we need a design system (tokens, component library) or a one-off page?
- Dark mode? RTL? accessibility constraints?
常见问题
为什么我的部分 Tailwind 样式不见了?
该技能说明,构建时必须扫描每个模板文件,除非加入安全列表,否则类名不能动态拼接。
我应该大量使用 @apply 吗?
不应该。该技能提醒不要过度使用,否则会失去工具类的优势。
它支持深色模式吗?
支持。该技能涵盖基于类的深色模式策略。
详情
作者的原始描述
Use when designing/implementing UI with Tailwind CSS (layout, typography, responsive, theming, component patterns). Includes quick recipes and conventions for clean, consistent web design.
repo: MengTo/Skills
热度
- GitHub 星标
- 7.2k
- 排名
- #13471
- 许可证
- MIT
- 更新时间
- 2026/11/1
评论
- …
同一仓库的更多技能
3d-cloth-material
7.2k帮你的智能体在 Three.js 中制作逼真的编织织物,包括纱线编织纹理、柔和光泽、自然褶皱、下摆和缝线。
3d-falling-leaves
7.2k帮你的智能体在 3D 场景中添加逼真的飘落树叶,树叶会翻滚、随风飘动,并在镜头移动时循环利用。
3d-four-seasons
7.2k帮你的智能体为 3D 场景添加春夏秋冬四季效果,无需重建场景即可改变植被、光线、天空和积雪。
3d-high-poly-models
7.2k帮你的智能体构建形状平滑、边缘可信的精细 3D 模型,然后制作在网页上运行流畅的轻量版本。