npm.io
2.10.3 • Published 3 months ago

@uiw/react-color-hue

Licence
MIT
Version
2.10.3
Deps
2
Size
21 kB
Vulns
0
Weekly
0
Stars
566

Using my app is also a way to support me:
Zipora: Zip/RAR/7Z Unarchiver Scap: Screenshot & Markup Edit Screen Test Deskmark Keyzer Vidwall Hub VidCrop Vidwall Mousio Hint Mousio Musicer Audioer FileSentinel FocusCursor Videoer KeyClicker DayBar Iconed Menuist Quick RSS Quick RSS Web Serve Copybook Generator DevTutor for SwiftUI RegexMate Time Passage Iconize Folder Textsound Saver Create Custom Symbols DevHub Resume Revise Palette Genius Symbol Scribe

React Color Hue

Buy me a coffee Follow On X npm version Open in unpkg

Hue Component is a subcomponent of @react-color.

react-color-hue

Install

npm i @uiw/react-color-hue

Usage

import React, { useState } from 'react';
import { hsvaToRgbaString } from '@uiw/color-convert';
import Hue from '@uiw/react-color-hue';

export default function Demo() {
  const [hsva, setHsva] = useState({ "h":0,"s":100,"v":100,"a":1 });
  return (
  <>
    <div style={{ display: "flex", gap: 10, flexDirection: "column", paddingBottom: 20 }}>
      <Hue
        hue={hsva.h}
        onChange={(newHue) => {
          setHsva({ ...hsva, ...newHue });
        }}
      />
      <Hue
        hue={hsva.h}
        reverse={true}
        onChange={(newHue) => {
          setHsva({ ...hsva, ...newHue });
        }}
      />
    </div>
    <div style={{ display: "flex", gap: 10, flexDirection: "row" }}>
      <Hue
        hue={hsva.h}
        direction="vertical"
        width={16}
        height={120}
        onChange={(newHue) => {
          setHsva({ ...hsva, ...newHue });
        }}
      />
      <Hue
        hue={hsva.h}
        direction="vertical"
        reverse={true}
        width={16}
        height={120}
        onChange={(newHue) => {
          setHsva({ ...hsva, ...newHue });
        }}
      />
    </div>
    <div style={{ background: hsvaToRgbaString(hsva), marginTop: 30, padding: 10 }}>
      {JSON.stringify(hsva)}
    </div>
  </>
  );
}
import React, { useState } from 'react';
import Hue from '@uiw/react-color-hue';

export default function Demo() {
  return (
    <Hue hue={undefined} />
  );
}

Props

import React from 'react';
import { AlphaProps } from '@uiw/react-color-alpha';
export interface HueProps extends Omit<AlphaProps, 'hsva' | 'onChange'> {
  onChange?: (newHue: {
    h: number;
  }) => void;
  hue: number;
}
declare const Hue: React.ForwardRefExoticComponent<HueProps & React.RefAttributes<HTMLDivElement>>;
export default Hue;

Contributors

As always, thanks to our amazing contributors!

Made with contributors.

License

Licensed under the MIT License.

Keywords