/ui
  • Components
  • Packages
  • About
  • Github
Menu
Components
Packages
Built by vorhdam at Nordaun. The source code is available on Github

Theme

A simple theme provider for any React or Next.js application to toggle between light and dark mode preferences.

Installation

bun add @nordaun/theme

Provider

/providers/theme.tsx
1import { ThemeProvider } from "@nordaun/theme";
2
3export function ProviderComponent({ children }: { children: React.ReactNode }) {
4 return (
5 <ThemeProvider
6 cookieName="THEME"
7 defaultTheme="system"
8 enableSystem
9 disableTransition
10 >
11 {children}
12 </ThemeProvider>
13 );
14}

Hook

/hooks/theme.tsx
1import { useTheme } from "@nordaun/theme";
2
3// eslint-disable-next-line react-hooks/rules-of-hooks
4const { theme, themes, setTheme } = useTheme();
5console.log("Current theme:", theme);
6console.log("All avialable themes:", themes);
7setTheme("system");