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

css-custom-properties

Skill này làm gì

Skill này kiểm tra stylesheet để tìm các giá trị cứng nên là design token dùng chung. Skill dành cho lập trình viên muốn việc đổi giao diện và thay đổi style toàn cục trở nên đơn giản.

Khi nào nên dùng

  • ✓Khi cùng một màu hoặc giá trị khoảng cách xuất hiện ở nhiều nơi.
  • ✓Khi bạn muốn thêm chế độ tối hoặc một chủ đề thương hiệu mới.
  • ✓Khi thay đổi một giá trị thiết kế buộc bạn phải sửa nhiều dòng.

Liên kết skill

https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/css-custom-properties/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/thedaviddias/Front-End-Checklist/blob/main/skills/css-custom-properties/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

“Hãy gom các màu thương hiệu và giá trị khoảng cách lặp lại trong stylesheet của tôi thành biến CSS tùy chỉnh dùng chung.”

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

Cách hoạt động

Agent định nghĩa các giá trị lặp lại thành biến tùy chỉnh trên phần tử gốc, rồi thay mỗi chỗ viết cứng bằng tham chiếu var, kèm giá trị dự phòng khi hữu ích.

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.

Use CSS custom properties for design tokens

Hard-coded color values and magic numbers scattered across CSS files make global changes (a rebrand, a dark mode, a spacing adjustment) require finding and updating dozens of individual lines. Custom properties centralize these values so one change propagates everywhere — and enable runtime theming that preprocessor variables cannot.

Quick Reference

  • Define reusable values as --variable-name on :root
  • Custom properties cascade and inherit — they can be overridden at any scope
  • Use var(--name, fallback) to provide fallback values
  • Custom properties are runtime values — JavaScript can read and write them

Check

Find hard-coded color values, spacing values, and font sizes in this CSS file that should be replaced with CSS custom properties.

Fix

Extract repeated and meaningful values into CSS custom properties on :root and replace all usages with var() references.

Explain

Explain CSS custom properties: how they differ from preprocessor variables, how cascade and inheritance work, and how to use them for theming.

Code Review

Review stylesheets, component styles, and responsive states related to Use CSS custom properties for design tokens. Flag exact selectors, declarations, or breakpoints that violate the rule in the rendered UI.


For full implementation details, code examples, and framework-specific guidance, see references/rule.md.

Rule page: https://frontendchecklist.io/rules/css/css-custom-properties

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

Biến CSS tùy chỉnh khác biến của bộ tiền xử lý thế nào?

Skill nói chúng là giá trị chạy lúc thực thi, có thể bị ghi đè ở mọi phạm vi, và JavaScript có thể đọc hoặc thay đổi.

Chúng có giúp làm chế độ tối không?

Có. Skill nói chúng cho phép đổi chủ đề lúc chạy mà biến của bộ tiền xử lý không làm được.

Giá trị dự phòng làm gì?

Nó cung cấp một giá trị dự phòng nếu biến CSS tùy chỉnh chưa được đặt.

Chi tiết

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

Use when reviewing stylesheets, component styles, and responsive behavior related to Use CSS custom properties for design tokens. Check the rendered layout across breakpoints and interaction states before proposing a fix.

repo: thedaviddias/Front-End-Checklist

Độ phổ biến

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