Reference
ColorPicker
A colour, chosen from swatches: (each a button, the chosen one pressed), with the browser's own picker, or typed as hex; bind: holds it as #rrggbb.
ColorPicker(bind: State, label: String, swatches: [String])
Since 6.2.0
label
Chosen: #0f766e
Example
state accent = "#0f766e"
ColorPicker(bind: accent, label: "Accent colour", swatches: ["#0f766e", "#1d4ed8", "#7c3aed", "#b91c1c", "#c2410c"])
Button("Preview").primary { style { background: {accent} } }
Text("Chosen: {accent}").muted
Props
| Prop | Type | Unset | Meaning |
|---|---|---|---|
bind: | State (required) | — | The |
label: | String (required) | — | What the colour is for: the group's name, and the start of its picker's and hex field's names |
swatches: | [String] | none | The colours offered as buttons before the picker: |
Attribute families: global, aria, data. Plus the 22 universal props every element takes: animate:, exit:, speed:, duration:, delay:, easing:, stagger:, on:, count:, shared:, class:, ref:, drag:, dragGroup:, dropValue:, dropAxis:, dropInside:, roving:, trapFocus:, mount:, update:, cleanup:.
Flags and cases
A flag is written after the parentheses with a dot: a Bool prop, or a case of one of the element's enum props. A case the enum lacks is an error with a hint.
No flags of its own.
Events
Every element also takes the props, the events and the attribute families listed on every element.
Slots
It takes no slots.
Renders with the class wf-color-picker, stable across releases, so a stylesheet may target it.