MCPcopy Index your code
hub / github.com/Wondermarin/react-color-palette

github.com/Wondermarin/react-color-palette @v7.3.1

Chat with this repo
repository ↗ · DeepWiki ↗ · release v7.3.1 ↗ · + Follow
34 symbols 84 edges 30 files 0 documented · 0% 4 cross-repo links
What it actually does AI analysis from the code graph — generated when you open this
loading…
README
<img alt="react-color-palette" src="https://github.com/Wondermarin/react-color-palette/raw/main/public/logo.png" width="128px" height="128px" />

🎨 Lightweight <ColorPicker /> component for React.

<a href="https://www.npmjs.com/package/react-color-palette">
  <img alt="npm" src="https://badgen.net/npm/v/react-color-palette?color=561ecb" />
</a>
<a href="https://www.npmjs.com/package/react-color-palette">
  <img alt="downloads" src="https://badgen.net/npm/dw/react-color-palette?color=561ecb" />
</a>
<a href="https://bundlephobia.com/result?p=react-color-palette">
  <img alt="size" src="https://badgen.net/bundlephobia/minzip/react-color-palette@latest?color=561ecb" />
</a>






<img src="https://github.com/Wondermarin/react-color-palette/raw/main/public/demo.apng" />

Installation

yarn

yarn add react-color-palette

npm

npm install react-color-palette

Usage

import { ColorPicker, useColor } from "react-color-palette";
import "react-color-palette/css";

export function App() {
  const [color, setColor] = useColor("#561ecb");

  return <ColorPicker color={color} onChange={setColor} />;
}

Examples

Usage rgb() in useColor()

import { ColorPicker, useColor } from "react-color-palette";
import "react-color-palette/css";

export function App() {
  const [color, setColor] = useColor("rgb(86 30 203)");

  return <ColorPicker color={color} onChange={setColor} />;
}

Usage <named-color> in useColor()

import { ColorPicker, useColor } from "react-color-palette";
import "react-color-palette/css";

export function App() {
  const [color, setColor] = useColor("cyan");

  return <ColorPicker color={color} onChange={setColor} />;
}

Custom Layout

import { Saturation, Hue, useColor } from "react-color-palette";
import "react-color-palette/css";

export function App() {
  const [color, setColor] = useColor("hsl(120 100% 50% / .5)");

  return (



      <Saturation height={300} color={color} onChange={setColor} />
      <Hue color={color} onChange={setColor} />



  );
}

HEX input only

import { ColorPicker, useColor } from "react-color-palette";
import "react-color-palette/css";

export function App() {
  const [color, setColor] = useColor("#123123");

  return <ColorPicker hideInput={["rgb", "hsv"]} color={color} onChange={setColor} />
}

onChangeComplete optional callback

import { ColorPicker, useColor, type IColor } from "react-color-palette";
import "react-color-palette/css";

export function App() {
  const [color, setColor] = useColor("#123123");

  const onChangeComplete = (color: IColor) => localStorage.setItem("color", color.hex);

  return <ColorPicker hideInput={["rgb", "hsv"]} color={color} onChange={setColor} onChangeComplete={onChangeComplete} />
}

API

<ColorPicker />

The main component, which includes: <Saturation />, <Hue />, <Alpha /> and <Fields /> components for instant use.

If you need a custom layout, then you can use <Saturation />, <Hue /> and <Alpha /> components separately, which are also exported from the library.

Prop Type Default Description
height number 200 Height of the Saturation component in pixels.
hideAlpha boolean false Hides the Alpha component.
hideInput (keyof IColor)[] | boolean false If boolean: hides all inputs if true or displays all inputs if false. If array: hides all inputs listed in the array.
color IColor Current color.
disabled boolean false Disables interactivity.
onChange Function Сallback function will be fired when color changes.
onChangeComplete Function Callback function will be fired when the interaction is complete with the color picker.

<Saturation />

Prop Type Default Description
height number Height of the saturation element in pixels.
color IColor Current color.
disabled boolean false Disables interactivity.
onChange Function Сallback function will be fired when color changes.
onChangeComplete Function Callback function will be fired when the interaction is complete with the saturation picker.

<Hue />

Prop Type Default Description
color IColor Current color.
disabled boolean false Disables interactivity.
onChange Function Сallback function will be fired when color changes.
onChangeComplete Function Callback function will be fired when the interaction is complete with the hue picker.

<Alpha />

Prop Type Default Description
color IColor Current color.
disabled boolean false Disables interactivity.
onChange Function Сallback function will be fired when color changes.
onChangeComplete Function Callback function will be fired when the interaction is complete with the alpha picker.

useColor()

Arg Type Default Description
initialColor TColor Initial сolor.

TColor

Value can be specified using one of the methods listed below:

IColor

Field Type
hex string
rgb IColorRgb
hsv IColorHsv

IColorRgb

Field Type
r number
g number
b number
a number

IColorHsv

Field Type
h number
s number
v number
a number

License

Code released under the MIT license.

Extension points exported contracts — how you extend this code

Core symbols most depended-on inside this repo

Shape

Function 13
Interface 11
Method 8
Class 2

Languages

TypeScript100%

Modules by API surface

src/services/color/color.service.ts13 symbols
src/hooks/use-bounding-client-rect/use-bounding-client-rect.hook.ts6 symbols
src/components/interactive/interactive.component.tsx3 symbols
src/utils/format/format.util.ts2 symbols
src/utils/is-touch/is-touch.util.ts1 symbols
src/utils/is-field-hide/is-field-hide.util.ts1 symbols
src/utils/float/float.util.ts1 symbols
src/utils/clamp/clamp.util.ts1 symbols
src/hooks/use-color/use-color.hook.ts1 symbols
src/components/saturation/saturation.component.tsx1 symbols
src/components/hue/hue.component.tsx1 symbols
src/components/fields/fields.component.tsx1 symbols

For agents

$ claude mcp add react-color-palette \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page