Chuyển đến nội dung
Skillpedia
Thương hiệu48k · #5922

tailwind-patterns

Skill này làm gì

Công cụ này giúp cấu hình và dùng các tính năng mới nhất của Tailwind CSS, như định nghĩa kiểu trực tiếp trong CSS, dùng truy vấn kích thước cho từng thành phần và tạo bố cục hiện đại.

Khi nào nên dùng

  • ✓Khi cấu hình Tailwind CSS phiên bản 4.
  • ✓Khi định nghĩa màu sắc, khoảng cách và phông chữ một cách có tổ chức.
  • ✓Khi tạo thiết kế thích ứng với các kích thước màn hình hoặc từng phần cụ thể của trang.

Liên kết skill

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/tailwind-patterns/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/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/tailwind-patterns/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

“Làm sao để thiết lập màu chính và màu phụ bằng hệ thống token mới?”

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

Cách hoạt động

Bạn có thể định nghĩa kiểu trực tiếp trong tệp CSS bằng chỉ thị `@theme`. Điều này giúp tổ chức màu sắc, phông chữ và khoảng cách hiệu quả hơn, và cho phép các tính năng mới như “container queries” để thành phần tự thích ứ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 Patterns (v4 - 2025)

Modern utility-first CSS with CSS-native configuration.

When to Use

Use this skill when configuring Tailwind v4, using CSS-first theme and design tokens, or implementing container queries and modern Tailwind patterns.


1. Tailwind v4 Architecture

What Changed from v3

v3 (Legacy) v4 (Current)
tailwind.config.js CSS-based @theme directive
PostCSS plugin Oxide engine (10x faster)
JIT mode Native, always-on
Plugin system CSS-native features
@apply directive Still works, discouraged

v4 Core Concepts

Concept Description
CSS-first Configuration in CSS, not JavaScript
Oxide Engine Rust-based compiler, much faster
Native Nesting CSS nesting without PostCSS
CSS Variables All tokens exposed as --* vars

2. CSS-Based Configuration

Theme Definition

@theme {
  /* Colors - use semantic names */
  --color-primary: oklch(0.7 0.15 250);
  --color-surface: oklch(0.98 0 0);
  --color-surface-dark: oklch(0.15 0 0);
  
  /* Spacing scale */
  --spacing-xs: 0.25rem;
  --spacing-sm: 0.5rem;
  --spacing-md: 1rem;
  --spacing-lg: 2rem;
  
  /* Typography */
  --font-sans: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

When to Extend vs Override

Action Use When
Extend Adding new values alongside defaults
Override Replacing default scale entirely
Semantic tokens Project-specific naming (primary, surface)

3. Container Queries (v4 Native)

Breakpoint vs Container

Type Responds To
Breakpoint (md:) Viewport width
Container (@container) Parent element width

Container Query Usage

Pattern Classes
Define container @container on parent
Container breakpoint @sm:, @md:, @lg: on children
Named containers @container/card for specificity

When to Use

Scenario Use
Page-level layouts Viewport breakpoints
Component-level responsive Container queries
Reusable components Container queries (context-independent)

4. Responsive Design

Breakpoint System

Prefix Min Width Target
(none) 0px Mobile-first base
sm: 640px Large phone / small tablet
md: 768px Tablet
lg: 1024px Laptop
xl: 1280px Desktop
2xl: 1536px Large desktop

Mobile-First Principle

  1. Write mobile styles first (no prefix)
  2. Add larger screen overrides with prefixes
  3. Example: w-full md:w-1/2 lg:w-1/3

5. Dark Mode

Configuration Strategies

Method Behavior Use When
class .dark class toggles Manual theme switcher
media Follows system preference No user control
selector Custom selector (v4) Complex theming

Dark Mode Pattern

Element Light Dark
Background bg-white dark:bg-zinc-900
Text text-zinc-900 dark:text-zinc-100
Borders border-zinc-200 dark:border-zinc-700

6. Modern Layout Patterns

Flexbox Patterns

Pattern Classes
Center (both axes) flex items-center justify-center
Vertical stack flex flex-col gap-4
Horizontal row flex gap-4
Space between flex justify-between items-center
Wrap grid flex flex-wrap gap-4

Grid Patterns

Pattern Classes
Auto-fit responsive grid grid-cols-[repeat(auto-fit,minmax(250px,1fr))]
Asymmetric (Bento) grid grid-cols-3 grid-rows-2 with spans
Sidebar layout grid grid-cols-[auto_1fr]

Note: Prefer asymmetric/Bento layouts over symmetric 3-column grids.


7. Modern Color System

OKLCH vs RGB/HSL

Format Advantage
OKLCH Perceptually uniform, better for design
HSL Intuitive hue/saturation
RGB Legacy compatibility

Color Token Architecture

Layer Example Purpose
Primitive --blue-500 Raw color values
Semantic --color-primary Purpose-based naming
Component --button-bg Component-specific

8. Typography System

…

Câu hỏi thường gặp

Khác nhau giữa “breakpoint” và “container query” là gì?

Breakpoint liên quan đến kích thước toàn màn hình, còn container query liên quan đến kích thước của phần tử cha, cho phép thành phần thích ứng độc lập với kích thước trang.

Làm sao để website tự chuyển sang chế độ tối khi hệ điều hành ở chế độ tối?

Bạn có thể cấu hình chế độ tối theo tùy chọn hệ thống bằng chiến lược “media” trong cấu hình Tailwind.

“Design tokens” là gì?

Đây là các biến đại diện cho giá trị thiết kế, như màu sắc và khoảng cách. Chúng giúp giữ tính nhất quán về hình ảnh và dễ cập nhật kiểu dáng trong toàn bộ dự án.

Chi tiết

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

Tailwind CSS v4 principles. CSS-first configuration, container queries, modern patterns, design token architecture.

repo: sickn33/agentic-awesome-skills

Độ phổ biến

Sao GitHub
48k
Vị trí xếp hạng
#5922
Giấy phép
MIT
Cập nhật
15/10/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ự