#Multi Theme Setup With ShadCN?

1 messages · Page 1 of 1 (latest)

mental lagoon
#

I want to implement multi-theme setup with shadcn and next-themes. Instead of just light & dark themes I would like to have red, blue, green, etc. Where each of them have their own light and dark variants.

I have been looking at the next-themes multi-theme example repo, but I cannot get it to work with even the simplest example.

As far as I can see I have everything setup the same as in their example repo, and have tried messing with the ThemeProvider configuration, etc. It is worth noting that my tailwind.config.ts is setup as shadcn does it by default and I still use tailwindcss v3.

If you have any ideas, any help is appreciated 🙏

// layout.tsx
export default async function RootLayout({
  children,
}: Readonly<{ children: React.ReactNode }>) {
  return (
    <html
      lang="en"
      suppressHydrationWarning
    >
      <body>
        <ThemeProvider
          defaultTheme="red"
          enableColorScheme
          themes={["default", "red"]}
          attribute={"class"}
        >
          {children}
        </ThemeProvider>
      </body>
    </html>
  );
}
/* globals.css */
@tailwind base;
@tailwind components;
@tailwind utilities;

@layer base {
  :root {
    --background: 0 0% 100%;
    --foreground: 240 10% 3.9%;
  }
  
  .dark {
    --background: 240 10% 3.9%;
    --foreground: 0 0% 98%;
  }

  html[data-theme="red"] {
    --background: 0 0% 100%;
    --foreground: 0 0% 3.9%;
  }

  html[data-theme="red"] .dark {
    --background: 0 0% 3.9%;
    --foreground: 0 0% 98%;
  }
}
eternal karmaBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)