UNPKG

@uiw/react-color-swatch

Version:

Color swatch component for React.

27 lines (26 loc) 1.11 kB
import React from 'react'; import { type HsvaColor, type ColorResult } from '@uiw/color-convert'; import type * as CSS from 'csstype'; export type SwatchPresetColor = { color: string; title?: string; } | string; export interface SwatchRectRenderProps extends React.HTMLAttributes<HTMLDivElement> { title: string; color: string; checked: boolean; style: CSS.Properties<string | number>; onClick: (evn: React.MouseEvent<HTMLDivElement, MouseEvent>) => void; } export interface SwatchProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange' | 'color'> { prefixCls?: string; color?: string; colors?: SwatchPresetColor[]; rectProps?: React.HTMLAttributes<HTMLDivElement>; rectRender?: (props: SwatchRectRenderProps) => JSX.Element | undefined; onChange?: (hsva: HsvaColor, color: ColorResult, evn: React.MouseEvent<HTMLDivElement, MouseEvent>) => void; addonAfter?: React.ReactNode; addonBefore?: React.ReactNode; } declare const Swatch: React.ForwardRefExoticComponent<SwatchProps & React.RefAttributes<HTMLDivElement>>; export default Swatch;