1.3.0 • Published 10 months ago

react-colorblender v1.3.0

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

Installation

npm install react-colorblender

Import

import { ColorPicker } from 'react-colorblender';

Usage

import React from 'react';
import { ColorPicker, useColor } from 'react-colorblender';

import 'react-colorblender/dist/style.css';

export default function Home() {
  const [color, setColor] = useColor('#ff0000');

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

API

ColorPicker

<ColorPicker color={color} onChange={setColor} />
PropertyRequiredDescriptionTypeDefault
colortrueThe color valueColor-
onChangetrueThe color change event(color: Color) => void-
widthfalseThe width of the pickernumber250
classNamefalseThe class name of the pickerstring-
hideAlphafalseHide the alpha sliderbooleanfalse

useColor

const [color, setColor] = useColor('#ff0000');
ArgsDescriptionType
initialColorThe initial colorColor

ColorPickerProps

interface ColorPickerProps {
  width?: number;
  hideAlpha?: boolean;
  hideInput?: boolean;
  color: Color;
  onChange: (color: Color) => void;
  className?: string;
}

Color

import type { HexColor, HsvaColor, RgbaColor } from 'colorblender';

type ColorType = HexColor | RgbaColor | HsvaColor;

class Color {
  hex: HexColor;
  rgb: RgbaColor;
  rgbString: string;
  hsv: HsvaColor;
  hsvString: string;

  constructor(color: ColorType, model: Models);
}

HexColor

type HexColor = string;

RgbaColor

interface RgbaColor {
  r: number;
  g: number;
  b: number;
  a: number;
}

HsvaColor

interface HsvaColor {
  h: number;
  s: number;
  v: number;
  a: number;
}

Roadmap

  • Picker with HEX
  • Alpha
  • RGB
  • HSV
  • HSL
  • HWB
  • CMYK
  • XYZ
  • LAB
  • LCH
  • Copy color
  • Custom css variables
  • Pick color from page
  • Multiple color models with useColor hook
  • And more...

Issues

Please file an issue for bugs, missing documentation, or unexpected behavior.

File an issue

LICENSE

MIT

1.2.0

10 months ago

1.1.5

11 months ago

1.3.0

10 months ago

1.2.1

10 months ago

1.1.1

1 year ago

1.1.4

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.1.0

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago