RepositoryTypeScript
pacocoursey

pacocoursey/next-themes

Perfect Next.js dark mode in 2 lines of code. Support System preference and any other theme with no flashing

6.4ksao
257fork
46issue
1lượt xem

Thành tựu nổi bật

Những danh hiệu mới nhất của dự án

1
TINIX TRENDING·Chủ đề: dark-theme

#1 Repository của tuần

2
TINIX TRENDING·Chủ đề: themes

#2 Repository của tuần

4
TINIX TRENDING·Chủ đề: dark-mode

#4 Repository của tuần

🌗 next-themes: Dark mode cho Next.js chỉ trong 2 dòng code

Thư viện nhỏ gọn mang lại hỗ trợ dark mode hoàn hảo cho Next.js với zero flash và đồng bộ toàn hệ thống.

next-themes là một abstraction nhẹ cho quản lý theme trong React, đặc biệt tối ưu cho Next.js. Dự án hỗ trợ cả hai kiến trúc pages/ và app/, kèm theo đó là cơ chế tránh hiện tượng flash khi tải trang (FOUC), đồng thời đồng bộ theme giữa các tab trình duyệt.

✨ Điểm nổi bật

  • Dark mode 2 dòng code: Chỉ cần bọc ứng dụng bằng ThemeProvider là hoạt động ngay.
  • Hỗ trợ ưu tiên hệ thống: Tự động áp dụng light/dark dựa trên prefers-color-scheme.
  • Không bấm nháy khi tải trang: Tối ưu cho cả SSR và SSG để tránh flash trắng.
  • Đồng bộ theme giữa các tab: Thay đổi theme ở một tab sẽ cập nhật ngay trên các tab khác.
  • Hỗ trợ Next.js 13 appDir: Tích hợp liền mạch với kiến trúc mới của Next.js.
  • Chọn selector tùy biến: Dùng class hoặc data-theme tùy thiết lập.
  • Hook useTheme: Truy cập theme hiện tại và hàm đổi theme dễ dàng.
  • Tùy chỉnh toàn diện: Cấu hình storageKey, defaultTheme, forcedTheme, enableSystem, enableColorScheme, disableTransitionOnChange, themes, attribute, value, nonce, scriptProps.

💡 Vì sao đáng chú ý

Không chỉ là một giải pháp dark mode đơn giản, next-themes còn giải quyết bài toán phức tập của SSR/SSG khi theme chưa được biết ở phía server — tránh lỗi hydration mismatch mà không cần thiết lập phứ tạp. Đặc biệt, nó hỗ trợ cả Tailwind CSS thông qua việc gán class vào phần tử <html>, giúp dự án chuyển đổi giữa light/dark một cách trơn tru và hiệu năng.


#DarkMode #NextJS #React #Themes #TiniX

Dự án tương tự

Khám phá các dự án và mô hình AI khác có sự tương đồng.

RepositoryTypeScript
shadcn-ui/ui

Composable, accessible components with thoughtful defaults. Build your own component library with code you can customize, extend, and make your own.

129.8k
Dec 2, 2026
RepositoryJavaScript
vercel/next.js

The React Framework

143.9k
Dec 1, 2026
RepositoryJavaScript
vercel/next.js

The React Framework

143.9k
Dec 1, 2026
RepositoryTypeScript
ChatGPTNextWeb/NextChat

✨ Zero-config AI chat assistant. No API key needed — sign up and instantly chat with GPT-5, Claude 4, Gemini 2.5, DeepSeek & 100+ top models. Pay-as-you-go saves you more. Available on Web, iOS, macOS, Android, Linux, Windows.

89.0k
Oct 20, 2026
RepositoryTypeScript
AykutSarac/jsoncrack.com

✨ Innovative and open-source visualization application that transforms various data formats, such as JSON, YAML, XML and CSV into interactive graphs.

44.7k
Nov 25, 2026
RepositoryTypeScript
trpc/trpc

🧙‍♀️ Move Fast and Break Nothing. End-to-end typesafe APIs made easy.

40.9k
Dec 1, 2026
RepositoryTypeScript
mantinedev/mantine

A fully featured React components library

32.0k
Nov 28, 2026
RepositoryTypeScript
darkreader/darkreader

Dark Reader Chrome and Firefox extension

22.6k
Nov 30, 2026
RepositoryTypeScript
daltonmenezes/aura-theme

✨ A beautiful dark theme for your favorite apps.

3.8k
Dec 20, 2025