Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@uiw/react-color-sketch

uiwjs113.6kMIT2.3.4TypeScript support: included

Color Sketch component for React.

react, react-color, react-component, color-picker, colorpicker, color picker, colorful, react-color-sketch, sketch, color, convert

readme

React Color Sketch

Buy me a coffee 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

`jsx mdx:preview import React, { useState } from 'react'; import Sketch from '@uiw/react-color-sketch';

function Demo() { const [hex, setHex] = useState("#fff"); const [disableAlpha, setDisableAlpha] = useState(false); return (

<Sketch style={{ marginLeft: 20 }} color={hex} disableAlpha={disableAlpha} onChange={(color) => { setHex(color.hex); }} /> <button onClick={() => setDisableAlpha(!disableAlpha)}> disableAlpha={disableAlpha.toString()} </button>
); }

export default Demo;


## Props

```ts
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;
  disableAlpha?: boolean;
  onChange?: (newShade: ColorResult) => void;
}
declare const Sketch: React.ForwardRefExoticComponent<SketchProps & React.RefAttributes<HTMLDivElement>>;
export default Sketch;

Contributors

As always, thanks to our amazing contributors!

Made with contributors.

License

Licensed under the MIT License.