@uiw/react-color-wheel

Color wheel

Usage no npm install needed!

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

README

React Color Wheel

npm bundle size npm version Open in unpkg

Wheel Component is a subcomponent of @react-color.

react-color-wheel

Install

npm i @uiw/react-color-wheel

Usage

import Wheel from '@uiw/react-color-wheel';

function Demo() {
  const [hsva, setHsva] = useState({ h: 0, s: 0, v: 68, a: 1 });
  return (
    <Wheel
      color={hsva}
      onChange={(color) => {
        setHsva({ ...hsva, ...color.hsva });
      }}
    />
  );
}

Props

import React from 'react';
import { HsvaColor, ColorResult } from '@uiw/color-convert';
export interface PointerProps extends React.HTMLAttributes<HTMLDivElement> {
  prefixCls?: string;
  top?: string;
  left: string;
  color?: string;
}
export declare const Pointer: ({ className, color, left, top, style, prefixCls }: PointerProps) => JSX.Element;
export interface WheelProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange' | 'color'> {
  prefixCls?: string;
  color?: string | HsvaColor;
  width?: number;
  height?: number;
  radius?: React.CSSProperties['borderRadius'];
  /** Starting angle of the color wheel's hue gradient, measured in degrees. */
  angle?: number;
  /** Direction of the color wheel's hue gradient; either clockwise or anticlockwise. Default: `anticlockwise` */
  direction?: 'clockwise' | 'anticlockwise';
  pointer?: ({ prefixCls, left, top, color }: PointerProps) => JSX.Element;
  onChange?: (color: ColorResult) => void;
}

License

Licensed under the MIT License.