Skip to content

Commit 73a420f

Browse files
committed
doc(Sketch): add example. #168
1 parent 75b62ef commit 73a420f

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

packages/color-sketch/README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,47 @@ function Demo() {
4545
export default Demo;
4646
```
4747

48+
Set presetColors Example
49+
50+
```jsx mdx:preview
51+
import React, { useState } from 'react';
52+
import Sketch from '@uiw/react-color-sketch';
53+
54+
const PRESET_COLORS = [
55+
'#D0021B',
56+
'#F5A623',
57+
'#f8e61b',
58+
'#8B572A',
59+
'#7ED321',
60+
'#417505',
61+
'#BD10E0',
62+
'#9013FE',
63+
];
64+
65+
function Demo() {
66+
const [hex, setHex] = useState("#fff");
67+
const [disableAlpha, setDisableAlpha] = useState(false);
68+
return (
69+
<div>
70+
<Sketch
71+
style={{ marginLeft: 20 }}
72+
color={hex}
73+
disableAlpha={disableAlpha}
74+
presetColors={PRESET_COLORS}
75+
onChange={(color) => {
76+
setHex(color.hex);
77+
}}
78+
/>
79+
<button onClick={() => setDisableAlpha(!disableAlpha)}>
80+
disableAlpha={disableAlpha.toString()}
81+
</button>
82+
</div>
83+
);
84+
}
85+
86+
export default Demo;
87+
```
88+
4889
## Props
4990

5091
```ts

0 commit comments

Comments
 (0)