6.2.2 • Published 1 year ago

react-color-palette-bh5wv v6.2.2

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Features

  • 🚀 Lightweight.
  • 💨 No dependencies.
  • 🛡️ Strict.

Installation

npm

npm install react-color-palette

yarn

yarn add react-color-palette

Usage

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

export const App = () => {
  const [color, setColor] = useColor("hex", "#121212");

  return <ColorPicker width={456} height={228} color={color} onChange={setColor} hideHSV dark />;
};

Benchmarks

LibraryMinifiedGzippedDependenciesTree ShakingType Declarations
react-color-palettenpm.ionpm.ionpm.ionpm.ionpm.io
react-colorfulnpm.ionpm.ionpm.ionpm.ionpm.io
react-input-colornpm.ionpm.ionpm.ionpm.ionpm.io
rc-color-pickernpm.ionpm.ionpm.ionpm.ionpm.io
react-colornpm.ionpm.ionpm.ionpm.ionpm.io

Overriding styles

If the default colors don't fit your project, you can always change them.

.rcp-light {
  --rcp-background: #ffffff;
  --rcp-input-text: #111111;
  --rcp-input-border: rgba(0, 0, 0, 0.1);
  --rcp-input-label: #717171;
}
.rcp-dark {
  --rcp-background: #181818;
  --rcp-input-text: #f3f3f3;
  --rcp-input-border: rgba(255, 255, 255, 0.1);
  --rcp-input-label: #999999;
}

API

ColorPicker Props

NameTypeDefaultDescription
widthnumberThe width of the color picker.
heightnumberwidthThe height of the color picker.
colorColorThe current Color.
onChangeFunctionA function to update Color.
onChangeCompleteFunctionundefinedA callback is called every time the user stops changing a color (mouseup event).
hideHEXboolfalseHide HEX input.
hideRGBboolfalseHide RGB input.
hideHSVboolfalseHide HSV input.
alphaboolfalseEnable alpha channel.
darkboolfalseColor theme.

useColor Arguments

NameTypeDefaultDescription
model"hex" | "rgb" | "hsv"The color model.
initColorstring | ColorRGB | ColorHSVThe initial color in the selected color model.

toColor Arguments

NameTypeDefaultDescription
model"hex" | "rgb" | "hsv"The color model.
colorstring | ColorRGB | ColorHSVThe color in the selected color model.

Color

FieldType
hexstring
rgbColorRGB
hsvColorHSV

ColorRGB

FieldType
rnumber
gnumber
bnumber
anumber | undefined

ColorHSV

FieldType
hnumber
snumber
vnumber
anumber | undefined

License

Code released under the MIT license.