@@ -12,22 +12,43 @@ Installing your package manager of choice:
1212
1313 pnpm i svelte-color-select
1414
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) :
1616
1717``` svelte
1818<script lang="ts">
19- import ColorSelect from 'svelte-color-select`
19+ import ColorSelect from 'svelte-color-select'
2020
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 }
2423</script>
2524
26- <ColorSelect bind:r bind:g bind:b />
25+ <ColorSelect bind:rgb />
2726```
2827
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 ` :
3045
3146``` 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 />
3354```
0 commit comments