ant-design/components/color-picker/demo/text-render.tsx
红果汁 b03ca50ab4
feat: ColorPicker show clear when value is not set (#45993)
* feat: color-picker show clear when value is not set

* fix: lint issue

* refactor: turn color defaultvalue to #1677ff

* test: update snap

* refactor: optimize demo type

* chore: back prettier

* chore: back prettier
2023-12-13 19:37:28 +08:00

32 lines
778 B
TypeScript

import React, { useState } from 'react';
import { DownOutlined } from '@ant-design/icons';
import { ColorPicker, Space } from 'antd';
const Demo = () => {
const [open, setOpen] = useState(false);
return (
<Space direction="vertical">
<ColorPicker defaultValue="#1677ff" showText />
<ColorPicker
defaultValue="#1677ff"
showText={(color) => <span>Custom Text ({color.toHexString()})</span>}
/>
<ColorPicker
defaultValue="#1677ff"
open={open}
onOpenChange={setOpen}
showText={() => (
<DownOutlined
rotate={open ? 180 : 0}
style={{
color: 'rgba(0, 0, 0, 0.25)',
}}
/>
)}
/>
</Space>
);
};
export default Demo;