Color field
A colour field that pairs a text box holding the #rrggbb value with the browser's colour picker.
zb:color-input zubazar/ui · free (MIT)
Basic usage
BLADE
The value box is the form's field; wire:model, name, required and the validation error go on it.
<div class="space-y-4">
<zb:color-input wire:model="urun_rengi" label="Product colour" hint="For example #c2410c" />
<zb:color-input name="marka_rengi" label="Brand colour" value="#2563eb" />
</div>
| Prop | Values |
|---|---|
label | The value box's label |
value | #rrggbb; without it the wire:model property's value |
Props
The values the component takes. What are props and slots?
| Prop | Type | Default | Description |
|---|---|---|---|
label | — | null | Label; with the required attribute a * follows it |
name | — | null | Field name; without it the wire:model value |
value | — | null | #rrggbb; without it the wire:model property's value, else empty (the picker starts black) |
hint | — | null | Help text below while there is no error |
input-class | — | null | The value box's own classes |
(attributes) | — | — | class, style, x-show, wire:key… go on the whole field; wire:model, required, disabled, aria-*, data-* and events on the value box. disabled turns the picker off too |
Developer notes
- The box and the picker follow each other: a colour picked fills the box and
wire:model,x-modelhear it; a value typed (#c2410c,#abcorc2410c) moves the picker. - Validate the value on the server too:
regex:/^#[0-9a-fA-F]{6}$/.
Accessibility
- Label
labelis tied to the hex value box with<label for>; the picker is named "Label: colour picker". Both are reached with Tab.- Hint and error
hintor the validation error is tied to the value box witharia-describedby; with an error the box getsaria-invalid="true".- Without JavaScript
- The value box is a plain text field: the colour is typed as
#rrggbband the form is sent. The picker is only a convenience.