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

dark-mode-css

Skill này làm gì

Skill này thêm phiên bản màu tối cho màu sắc của website. Skill dành cho lập trình viên muốn trang dễ nhìn vào ban đêm và tôn trọng cài đặt thiết bị.

Khi nào nên dùng

  • ✓Khi người xem yêu cầu chủ đề tối để đọc vào ban đêm.
  • ✓Khi website có màu cố định trông sai trên nền tối.
  • ✓Khi bạn muốn website theo cài đặt sáng hoặc tối trên thiết bị của từng người xem.

Liên kết skill

https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/dark-mode-css/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/dark-mode-css/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ể thêm chế độ tối vào website của tôi và tự theo cài đặt hệ thống không?”

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

Cách hoạt động

Agent chuyển các màu sang giá trị có tên riêng và đặt giá trị khác cho chế độ tối. Nó cũng có thể thêm một nút gạt để người xem tự chọn 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.

Support dark mode with prefers-color-scheme

More than half of users prefer dark mode for reduced eye strain, especially in low-light environments. Users with photosensitivity rely on it. Implementing dark mode via prefers-color-scheme respects the user's OS preference without them needing to find a toggle, and CSS custom properties make it a clean, maintainable addition rather than a disruptive refactor.

Quick Reference

  • Use @media (prefers-color-scheme: dark) to apply dark mode styles
  • Define light/dark colors as CSS custom properties on :root for easy switching
  • Support a manual toggle by storing preference in localStorage and setting a data-theme attribute
  • Ensure dark mode colors maintain WCAG contrast ratios

Check

Check if this CSS supports dark mode. Look for prefers-color-scheme usage or a data-theme attribute pattern. Identify any hard-coded colors that would look wrong in dark mode.

Fix

Implement dark mode by extracting colors to CSS custom properties and redefining them inside a prefers-color-scheme: dark media query.

Explain

Explain how to implement dark mode with CSS custom properties, the prefers-color-scheme media query, and a JavaScript toggle for user preference.

Code Review

Review stylesheets, component styles, and responsive states related to Support dark mode with prefers-color-scheme. 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/dark-mode-css

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

Trang biết người xem muốn chế độ tối bằng cách nào?

Trình duyệt báo cài đặt của thiết bị, và trang dùng nó để chọn màu tối tự động.

Người xem có thể tự chọn chủ đề không?

Có. Skill mô tả một nút gạt thủ công, và lựa chọn sẽ được lưu trong trình duyệt.

Chữ có còn dễ đọc trong chế độ tối không?

Skill nói cần giữ độ tương phản đủ cao để đạt tiêu chuẩn truy cập cho chữ.

Chi tiết

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

Use when reviewing stylesheets, component styles, and responsive behavior related to Support dark mode with prefers-color-scheme. 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
#2807
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ự