1.0.0 • Published 2 years ago

color-picker-react-component v1.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

颜色选择器

选择常用颜色值,具有推荐颜色、最近使用颜色、拾色器、自定义颜色等功能。

图例

image.png

安装

npm install -s color-picker-react

使用

import React, { useState } from 'react';
import ColorPicker from 'color-picker-react';

export default () => {
  const [color, setColor] = useState('#fff');
  const [visible, setVisible] = useState(false);
  return (
    <>
      <div
        color={color}
        style={{
          width: 20,
          height: 20,
          border: '1px solid #ccc',
          backgroundColor: color,
        }}
      />
      <ColorPicker
        color={color}
        visible={visible}
        onChange={(color: string) => setColor(color)}
        onVisibleChange={(v: boolean) => setVisible(v)}
      />
    </>
  );
};

参数说明

参数名含义默认值备注
color颜色值'#000'-
visible是否可见true-
recommendedColors自定义推荐颜色--
localStorageKey自定义key'color_picker_recent_color'最近颜色使用的localStorage唯一键值
showPipetteColor是否显示拾色器true-
showMoreColor是否显示更多颜色true-
className类名''-
style样式对象{}-
onChange监听颜色变化-({ color: string; }) => void
onVisibleChange监听显示变化-(visible: boolean) => void
1.0.0

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago