← Back to Table of Contents
Summary
Preset color picker featuring horizontal swatch pills with optional section headers and hover tooltips. Ideal for theme selection, category coloring, or any case where users choose from a predefined palette.
Basic usage
Standard Theme Colors
State & validation
Stored value
State is the array key from colors(), not the hex value. This allows you to change the hex values in your code without breaking existing database records.
Validation rules (built-in)
Configuration API
All methods accept Closure unless noted.
Real-world examples
Status Color Picker
Compact Palette
Interaction, contrast and lifecycle
Tooltip labels use compact 4px vertical and 8px horizontal padding.
White and black swatches keep a visible edge in both themes. The selected ring uses
an independent contrasting color, so selection remains visible even when the swatch
matches the page background. The initial selection, radio semantics and tab stop
are rendered by PHP; there is no introductory selection animation on reload.
- Tab enters the group once, at the selected option (or the first option).
- Arrow keys select and focus the next or previous color, wrapping at the ends.
- RTL reverses horizontal arrows. Home and End select the first and last option.
- Space and Enter activate the focused swatch through its native button.
disabled() renders disabled buttons and prevents changes. required() rejects an empty value.
- Reduced motion disables selection and hover transitions.
Each rendered field owns its stylesheet and small JS entry through the FLEX asset
runtime. It has no global listeners, timers, polling or network requests for colors.
Dynamic palettes and labels are evaluated on the server. Removed keys must be
replaced or cleared in your application; they fail validation if submitted.
Palette values accept CSS colors, including hex, named colors, RGB/HSL and CSS
variables. Empty keys/colors and CSS declaration delimiters are rejected. A palette
is developer configuration, not arbitrary CSS from submitted form data.
Playground
/admin/flex-fields/color-swatch
See Playground for setup.
CSS classes (reference)
Last modified on October 16, 2026