A color picker that outputs hex text: a saturation/brightness area to drag, a hue slider, an optional opacity slider, a hex field and a row of preset swatches.
<.color_picker field={@form[:color]} label="Stage color" />
<.color_picker name="tag" value="#4C3FE0" presets={~w(#EB3B2F #F5A214 #18996E)} />
<.color_picker field={@form[:overlay]} alpha locale="pt_BR" />
<.color_picker name="brand" variant="swatches" hex_field presets={~w(#0D8F91 #2F5FD0 #8A5CD6)} />The form gets #6366F1 (upper case, #RRGGBB; with alpha a translucent color is
#RRGGBBAA) through a hidden input named like the field; every change fires a bubbling
input event from it, so phx-change runs. The behaviour lives in the LedgerUI.ColorPicker
hook (priv/static/ledger_ui/hooks/color_picker.js), so the picker needs a stable id.
popover draws the picker on a lu-pop pad surface (300px), as in the reference of the
design; otherwise the picker has no surface of its own.
Summary
Functions
Renders the color picker.
Functions
Renders the color picker.
Attributes
id(:string) - Defaults tonil.name(:string) - Defaults tonil.value(:string)field(Phoenix.HTML.FormField) - Defaults tonil.default(:string) - Defaults to"#4C3FE0".label(:string) - Defaults tonil.label_class(:any) - Defaults tonil.help(:string) - Defaults tonil.errors(:list) - Defaults to[].alpha(:boolean) - Defaults tofalse.presets(:list) - Defaults to["#4C3FE0", "#2763E6", "#1693CC", "#18996E", "#31A35B", "#F5A214", "#F06B0C", "#EB3B2F", "#DB428F", "#606A78"].swatches(:list) - The same aspresets; it wins when given. Defaults tonil.locale(:string) - Defaults to"en". Must be one of"en", or"pt_BR".labels(:map) - Defaults to%{}.variant(:string) - Defaults to"full". Must be one of"full", or"swatches".hex_field(:boolean) - Defaults tofalse.hex_label(:any) - Defaults to"Hex".swatch_size(:string) - Defaults tonil.Must be one ofnil,"","sm","md", or"lg".popover(:boolean) - Defaults tofalse.disabled(:boolean) - Defaults tofalse.on_change(:string) - Defaults tonil.target(:any) - Defaults tonil.wrapper_class(:any) - Defaults tonil.class(:any) - Defaults tonil.- Global attributes are accepted.