Black Friday · Save 40% on Intent UI Design licenses with code UI2026.· 4 days left

Next.js

Next themes

Use next-themes to manage dark mode in Next.js. The switcher uses SunIcon and MoonIcon from @heroicons/react.

npm install next-themes @heroicons/react

Provider and switcher

Create the theme provider and switcher:

Loading source code...

Usage

Add the provider to your root layout:

import { Providers } from '@/components/providers'

export default function RootLayout({ children }: Readonly<{ children: React.ReactNode }>) {
  return (
    <html lang="en" suppressHydrationWarning>
      <body>
        <Providers>
          {children}
        </Providers>
      </body>
    </html>
  )
}
Design