React Color Sketch
Sketch Component is a subcomponent of @react-color
.
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.