Color controls
Color controls patterns built with StyloftCSS and native HTML.
ColorArea
A color-area surface and native range control. Two-dimensional pointer interaction and synchronized color output require application code.
View HTML / PlaygroundHTML source
<div class="sl-stack">
<div class="sl-color-area" style="--sl-color: #6556dd" aria-hidden="true"></div>
<div class="sl-field">
<label class="sl-label" for="ref-saturation">Saturation</label
><input
class="sl-color-range"
id="ref-saturation"
type="range"
min="0"
max="100"
value="70"
/>
</div>
</div>ColorField
An editable hexadecimal field with a native format constraint. Color preview synchronization is application logic.
View HTML / PlaygroundHTML source
<div class="sl-field">
<label class="sl-label" for="ref-color-field">Hex color</label
><input
class="sl-input"
id="ref-color-field"
pattern="#[0-9A-Fa-f]{6}"
value="#6556dd"
maxlength="7"
/>
</div>ColorPicker
The browser supplies the color picker; no component JavaScript.
View HTML / PlaygroundHTML source
<div class="sl-field">
<label class="sl-label" for="ref-color-picker">Accent color</label
><input class="sl-color-input" type="color" id="ref-color-picker" value="#6556dd" />
</div>ColorSlider
A native range control. Connect hue-to-color conversion in your application.
View HTML / PlaygroundHTML source
<div class="sl-field">
<label class="sl-label" for="ref-hue">Hue in degrees</label
><input
class="sl-color-range"
type="range"
id="ref-hue"
min="0"
max="360"
value="220"
/>
</div>ColorSwatch
Static color samples with accessible names.
View HTML / PlaygroundHTML source
<div class="sl-cluster sl-gap-4">
<span
class="sl-swatch"
style="--sl-color: #6556dd"
role="img"
aria-label="Purple, hexadecimal 6556dd"
></span
><span
class="sl-swatch"
style="--sl-color: #16a6b6"
role="img"
aria-label="Teal, hexadecimal 16a6b6"
></span>
</div>ColorSwatchPicker
Native radio selection with a visible selected state. Theme updates are application logic.
View HTML / PlaygroundHTML source
<fieldset class="sl-stack">
<legend>Choose a sample accent</legend>
<div class="sl-cluster sl-gap-4">
<label class="sl-swatch-choice"
><input
type="radio"
name="ref-accent"
value="#6556dd"
aria-label="Purple"
checked /><span
class="sl-swatch"
style="--sl-color: #6556dd"
aria-hidden="true"
></span></label
><label class="sl-swatch-choice"
><input type="radio" name="ref-accent" value="#16a6b6" aria-label="Teal" /><span
class="sl-swatch"
style="--sl-color: #16a6b6"
aria-hidden="true"
></span></label
><label class="sl-swatch-choice"
><input type="radio" name="ref-accent" value="#df7654" aria-label="Coral" /><span
class="sl-swatch"
style="--sl-color: #df7654"
aria-hidden="true"
></span
></label>
</div>
</fieldset>Classes beginning with sl- come from StyloftCSS. Examples with demo- classes also use our optional demo extension CSS ↓. Load it after the core to reproduce those details.