File tree Expand file tree Collapse file tree 1 file changed +41
-0
lines changed
Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -45,6 +45,47 @@ function Demo() {
4545export 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
You can’t perform that action at this time.
0 commit comments