@uiw/react-color-sketch

Color Sketch component for React.

Usage no npm install needed!

<script type="module">
  import uiwReactColorSketch from 'https://cdn.skypack.dev/@uiw/react-color-sketch';
</script>

README

React Color Sketch

npm bundle size npm version Open in unpkg

Sketch Component is a subcomponent of @react-color.

react-color-sketch

Install

npm i @uiw/react-color-sketch

Usage

import Sketch from '@uiw/react-color-sketch';

function Demo() {
  const [hex, setHex] = useState("#fff");
  return (
    <Sketch
      style={{ marginLeft: 20 }}
      color={hex}
      onChange={(color) => {
        setHex(color.hex);
      }}
    />
  );
}

Props

import React from 'react';
import { HsvaColor, ColorResult } from '@uiw/color-convert';
import { SwatchPresetColor } from '@uiw/react-color-swatch';
export interface SketchProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange' | 'color'> {
  prefixCls?: string;
  width?: number;
  color?: string | HsvaColor;
  presetColors?: false | SwatchPresetColor[];
  editableDisable?: boolean;
  onChange?: (newShade: ColorResult) => void;
}

License

Licensed under the MIT License.