Docs
Installation

Installation

How to install dependencies and structure your app.

Create project

Run the init command to create a new Next.js project or to setup an existing one:

Terminal
npx shadcn@latest init

Configure components.json

You will be asked a few questions to configure components.json:

Which style would you like to use? › New York
Which color would you like to use as base color? › Zinc
Do you want to use CSS variables for colors? › no / yes

Install next-themes

Terminal
npm install next-themes

Create a theme provider

components/theme-provider.tsx
"use client";
 
import * as React from "react";
import { ThemeProvider as NextThemesProvider } from "next-themes";
import { type ThemeProviderProps } from "next-themes/dist/types";
 
export function ThemeProvider({ children, ...props }: ThemeProviderProps) {
  return <NextThemesProvider {...props}>{children}</NextThemesProvider>;
}

Wrap your root layout

Add the ThemeProvider to your root layout.

app/layout.tsx
import { ThemeProvider } from "@/components/theme-provider";
 
export default function RootLayout({ children }: RootLayoutProps) {
  return (
    <>
      <html lang="en" suppressHydrationWarning>
        <head />
        <body>
          <ThemeProvider
            attribute="class"
            defaultTheme="system"
            enableSystem
            disableTransitionOnChange
          >
            {children}
          </ThemeProvider>
        </body>
      </html>
    </>
  );
}

Add a mode toggle

Place a mode toggle on your site to toggle between light and dark mode.

That's it

You can now start adding components to your project.

built by abhiroop. source code available on github.