Chuyển đến nội dung
Skillpedia
Website và giao diện (frontend)7.2k · #13471

tailwindcss

Skill này làm gì

Skill này hướng dẫn việc dùng Tailwind CSS, một công cụ tạo kiểu web theo tiện ích. Phù hợp với lập trình viên xây giao diện muốn khoảng cách và kiểu chữ nhất quán mà không cần nhiều CSS tùy chỉnh.

Khi nào nên dùng

  • ✓Khi bạn đang xây giao diện web và muốn tạo kiểu nhanh, nhất quán bằng các class tiện ích.
  • ✓Khi bạn cần bố cục đáp ứng, trạng thái khi di chuột hoặc chế độ tối trong dự án Tailwind.
  • ✓Khi các class Tailwind bị thiếu trên môi trường production và bạn cần tìm nguyên nhân.

Liên kết skill

https://github.com/MengTo/Skills/blob/main/agent-skills/web-design/tailwindcss/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/MengTo/Skills/blob/main/agent-skills/web-design/tailwindcss/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Bạn có thể tạo kiểu cho biểu mẫu đăng nhập này bằng Tailwind để nó gọn trên điện thoại và có chế độ tối không?”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Agent thêm các class tiện ích trực tiếp vào đánh dấu, dùng tiền tố đáp ứng, biến thể trạng thái và thiết lập chế độ tối. Agent khuyên biến các mẫu lặp lại thành component trước khi dùng các quy tắc kiểu nhỏ có thể tái sử dụng.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

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?
Câu hỏi thường gặp

Vì sao một số kiểu Tailwind bị thiếu?

Skill nói công cụ build phải quét mọi tệp mẫu, và tên class không được tạo động trừ khi đưa vào danh sách an toàn (safelist).

Có nên dùng @apply nhiều không?

Không. Skill cảnh báo không nên dùng quá nhiều, vì điều đó làm mất lợi ích của class tiện ích.

Có xử lý chế độ tối không?

Có. Skill bao gồm chiến lược chế độ tối dựa trên class.

Chi tiết

Mô tả gốc của tác giả

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

Độ phổ biến

Sao GitHub
7.2k
Vị trí xếp hạng
#13471
Giấy phép
MIT
Cập nhật
1/11/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự