@@ -12,22 +12,43 @@ Installing your package manager of choice:
12
12
13
13
pnpm i svelte-color-select
14
14
15
- Import into your component and bind ` r ` , ` g ` , and ` b ` values to it :
15
+ Import into your component and pass an ` { r, g, b } ` object to the ` rgb ` prop (with channels normalized 0–1) :
16
16
17
17
``` svelte
18
18
<script lang="ts">
19
- import ColorSelect from 'svelte-color-select`
19
+ import ColorSelect from 'svelte-color-select'
20
20
21
- let r = 102
22
- let g = 51
23
- let b = 153
21
+ // https://medium.com/@valgaze/the-hidden-purple-memorial-in-your-web-browser-7d84813bb416
22
+ let rgb: RGB = { r: 0.4, g: 0.2, b: 0.6 }
24
23
</script>
25
24
26
- <ColorSelect bind:r bind:g bind:b />
25
+ <ColorSelect bind:rgb />
27
26
```
28
27
29
- Alternatively, you can set the initial rgb values and listen to the ` change ` event to see the updates in both rgb and okhsv format:
28
+ ### Oklab
29
+
30
+ The [ Oklab] ( https://bottosson.github.io/posts/oklab/ ) colorspace is supported by using a ` oklab ` prop instead of ` rgb ` :
31
+
32
+ ``` svelte
33
+ <script lang="ts">
34
+ import ColorSelect, { type Oklab } from 'svelte-color-select'
35
+
36
+ let oklab: OKlab = { l: 0.44, a: 0.088, b: -0.134 }
37
+ </script>
38
+
39
+ <ColorSelect bind:oklab />
40
+ ```
41
+
42
+ ### Okhsv
43
+
44
+ The [ Okhsv] ( https://bottosson.github.io/posts/colorpicker/ ) colorspace is supported by using a ` okhsv ` prop instead of ` rgb ` :
30
45
31
46
``` svelte
32
- <ColorSelect {r} {g} {b} on:change={e => console.log(e.detail)} />
47
+ <script lang="ts">
48
+ import ColorSelect, { type OKhsv } from 'svelte-color-select'
49
+
50
+ let okhsv: OKhsv = { h: 303.37, s: 0.806, v: 0.608 }
51
+ </script>
52
+
53
+ <ColorSelect bind:okhsv />
33
54
```
0 commit comments