跳到正文
Skillpedia
网站与界面(前端)7.2k · #13471

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。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/MengTo/Skills/blob/main/agent-skills/web-design/tailwindcss/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 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 @apply for 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 @apply and 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/cva when needed.

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

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能