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

naming-conventions

Skill này làm gì

Skill này rà soát tên các class CSS và gợi ý một kiểu đặt tên thống nhất như BEM. Skill dành cho lập trình viên front-end và các nhóm muốn kiểu dáng dễ tìm và dễ sửa.

Khi nào nên dùng

  • ✓Khi bạn nhờ agent dọn dẹp hoặc chuẩn hóa tên các class CSS.
  • ✓Khi khó biết một class làm gì và các kiểu cứ bị xung đột giữa các thành phần.
  • ✓Khi bạn bắt đầu dự án mới và muốn có một quy ước đặt tên rõ ràng ngay từ đầu.

Liên kết skill

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

“Tên các class CSS của tôi đang rất lộn xộn. Bạn có thể đổi chúng theo một kiểu thống nhất như BEM không?”

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

Cách hoạt động

Agent rà soát tên class trong các file stylesheet và viết lại theo dạng block, element và modifier. Agent giữ tên ở dạng kebab-case và tách các class tiện ích khỏi kiểu của thành phần.

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 consistent CSS naming conventions

Without a naming convention, class names become a guessing game — does .active mean the nav item is active, the button is pressed, or a form field has focus? With BEM or a similar methodology, .button--active is unambiguous. This reduces the time spent searching for existing styles and prevents accidental style conflicts.

Quick Reference

  • BEM (Block__Element--Modifier) is the most widely adopted naming convention
  • Consistent naming lets you understand a class's purpose without reading its styles
  • Namespace utility classes and JS hooks separately from component styles
  • Use kebab-case for class names (not camelCase or snake_case)

Check

Audit the class names in this CSS file. Are they consistently named? Do they follow a clear convention? Are there any ambiguous names that could conflict?

Fix

Rename classes to follow BEM methodology: Block, Block__Element, Block--Modifier pattern.

Explain

Explain BEM naming convention, why naming conventions matter, and how to apply BEM to a real component.

Code Review

Review stylesheets, component styles, and responsive states related to Use consistent CSS naming conventions. 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/naming-conventions

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

BEM là gì?

BEM là viết tắt của Block, Element và Modifier. Kiểu đặt tên này giúp tên class có cấu trúc rõ ràng, ví dụ button--active.

Vì sao nên dùng kebab-case?

Skill khuyên dùng kebab-case thay vì camelCase hoặc snake_case để tên class được đồng nhất.

Các hook JavaScript có nên có tên riêng không?

Có. Skill gợi ý đặt các hook JavaScript trong một namespace riêng, tách khỏi kiểu của thành phần.

Chi tiết

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

Use when reviewing stylesheets, component styles, and responsive behavior related to Use consistent CSS naming conventions. 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
#2946
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ự