Forms
Color picker
A text field with a color swatch; the swatch opens a flat picker. Type any CSS color, drag, pick a preset — or grab a color from anywhere on screen.
<input class="form-control form-color" value="#2563eb" name="brand">
<!-- options -->
<input class="form-control form-color" data-moey-format="rgb" data-moey-alpha> <!-- rgba(…) with an opacity slider -->
<input class="form-control form-color" data-moey-swatches="#16a34a, #2563eb, #dc2626"> <!-- your presets ("false" = none) -->
- It's still a normal text input — it submits with the form and fires the usual
input(while picking) andchange(when the picker closes) events. Plain<input type="color">fields (like.form-control-color) get the Moey picker automatically too — opened from their swatch, value kept as#rrggbb; adddata-moey-color="native"to keep the browser's own picker. - Type anything the browser understands:
#2563eb,rgb(),hsl(),oklch(),tomato… - Picker — saturation/brightness area, hue and opacity sliders, a value field with a format switch (HEX → RGB → HSL), and presets (Moey's palette by default).
- Eyedropper — picks a color from anywhere on screen (shown in browsers that support it: Chrome, Edge).
- Keyboard — Alt+↓ in the field opens it; arrow keys move the area (Shift for bigger steps) and the sliders; Esc closes.
| Attribute | What it does |
|---|---|
data-moey-format | hex (default) · rgb · hsl — what's written into the input |
data-moey-alpha | Adds the opacity slider (hex becomes #rrggbbaa when not fully opaque) |
data-moey-swatches | Comma-separated presets, or "false" for none |
Brand colors
A small settings form: each color has its own presets.
<div class="card max-w-lg"><div class="card-body grid g-4">
<div class="field span-12 md:span-6">
<label class="form-label" for="cpx-primary">Primary</label>
<input class="form-control form-color" id="cpx-primary" value="#2563eb" data-moey-swatches="#2563eb, #7c3aed, #0891b2, #16a34a">
</div>
<div class="field span-12 md:span-6">
<label class="form-label" for="cpx-accent">Accent</label>
<input class="form-control form-color" id="cpx-accent" value="#f59e0b" data-moey-swatches="#f59e0b, #ef4444, #ec4899, #84cc16">
</div>
<div class="field span-12">
<label class="form-label" for="cpx-bg">Banner background (with opacity)</label>
<input class="form-control form-color" id="cpx-bg" value="rgba(37, 99, 235, 0.12)" data-moey-format="rgb" data-moey-alpha>
</div>
</div></div>
Compact swatch
A plain type="color" input — just the swatch, still the Moey picker.
<input class="form-control form-control-color" type="color" value="#16a34a" aria-label="Label color">
<input class="form-control form-control-color" type="color" value="#e11d48" aria-label="Tag color">