React Color Alpha
Alpha is a subcomponent of @react-color
.
Install
npm i @uiw/react-color-alpha
Usage
import Alpha from '@uiw/react-color-alpha';
function Demo() {
const [hsva, setHsva] = useState({ h: 0, s: 0, v: 68, a: 1 });
return (
<Alpha
hsva={hsva}
onChange={(newAlpha) => {
setHsva({ ...hsva, ...newAlpha });
}}
/>
);
}
Props
import { HsvaColor } from '@uiw/color-convert';
import { Interaction } from '@uiw/react-drag-event-interactive';
declare const BACKGROUND_IMG = 'data:image/png;base64,....'
interface AlphaProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'> {
prefixCls?: string;
width?: React.CSSProperties['width'];
height?: React.CSSProperties['height'];
hsva: HsvaColor;
pointer?: ({ prefixCls, left }: PointerProps) => JSX.Element;
radius?: React.CSSProperties['borderRadius'];
background?: string;
bgProps?: React.HTMLAttributes<HTMLDivElement>;
innerProps?: React.HTMLAttributes<HTMLDivElement>;
direction?: 'vertical' | 'horizontal';
onChange?: (newAlpha: { a: number; }, offset: Interaction) => void;
}
interface PointerProps extends React.HTMLAttributes<HTMLDivElement> {
prefixCls?: string;
left?: string;
top?: string;
}
License
Licensed under the MIT License.