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

Color

A simple color provider for any React or Next.js application to enable you view your components the way you like.

Installation

bun add @nordaun/color

Provider

/providers/color.tsx
1import { ColorProvider } from "@nordaun/color";
2
3export function ProviderComponent({ children }: { children: React.ReactNode }) {
4 return (
5 <ColorProvider
6 cookieName="COLOR"
7 classPrefix="color-"
8 colors={["red", "green", "blue"]}
9 defaultColor="red"
10 >
11 {children}
12 </ColorProvider>
13 );
14}

Hook

/hooks/color.tsx
1import { useColor } from "@nordaun/color";
2
3// eslint-disable-next-line react-hooks/rules-of-hooks
4const { color, colors, setColor } = useColor();
5console.log("Current color:", color);
6console.log("All avialable colors:", colors);
7setColor("red");