Skip to main content
ColorSwatchField ← Back to Table of Contents

Summary

Preset color picker: horizontal swatch pills with optional section header and tooltips.

Basic usage

State format

Stores the array key from colors(), e.g. 'indigo', not #6366f1.

Validation

Configuration API

colors(array|Closure $colors)

Map of key => hex (or CSS color). Required for meaningful UI.

sectionLabel(string|Closure|null $label)

Optional heading above swatches.

sectionIcon(string|BackedEnum|Htmlable|Closure|null $icon)

Icon next to section label. When label is set and icon omitted, uses config color_swatch_section_icon or GravityIcon::Palette.

tooltips(bool|array|Closure $tooltips = true)

true = auto labels from keys; false = no tooltips; array = per-key labels.

size(string|ControlSize|Closure $size)

sm, md, lg. Default: md.

Public helper methods

FlexField schema config

CSS classes

Implementation notes

  • Keys are persisted; map to hex in your application layer or accessor.
  • isLightSwatch() detects white swatches for contrast borders.