@nordaun/color
v1.0.0
Published
A simple color provider and context for your React apps.
Readme
@nordaun/color
A simple color provider and context for your React apps.
Install
npm install @nordaun/color
#or
yarn add @nordaun/color
#or
pnpm add @nordaun/color
#or
bun add @nordaun/colorUsage
Add this to your layout or app file (where your providers are)
// provider-demo.tsx
import { ColorProvider } from "@nordaun/color";
<ColorProvider
cookieName="COLOR"
classPrefix="color-"
colors={["red", "green", "blue"]}
defaultColor="red"
>
{children}
</ColorProvider>;Use the useColor() function to get or set a color
// hook-demo.tsx
import { useColor } from "@nordaun/color";
const { color, colors, setColor } = useColor();
console.log("Current color:", color);
console.log("All avialable colors:", colors);
setColor("red");Example
The site that host the documentation of this package was built using @nordaun/color.
You can interact with the color selector at the header of this page
