FSAI Design System
Components

ColorInput

Hex color picker input that combines a swatch trigger, popover picker, and optional text input.

Overview

ColorInput is the shared-ui color picker used in brand configuration, template builders, and tagging flows.

It combines three things:

  • a clickable color swatch
  • a popover HexColorPicker
  • an optional inline hex text input

This makes it a better fit than a plain text field when users need to both see and edit a color value.

Basic Usage

import { ColorInput } from '@fsai/shared-ui';

<ColorInput
  label="Primary Color"
  color={value}
  onChange={setValue}
  onBlur={handleBlur}
/>

The default behavior shows both the swatch and the hex input.

Swatch-Only Usage

Use withInput={false} when the color control needs to stay very compact:

<ColorInput
  color={value}
  onChange={setValue}
  withInput={false}
/>

This pattern is common in dense builders and inline creation flows.

Props

PropTypeDefaultDescription
colorstring | nullCurrent hex color value.
onChange(color: string) => voidCalled whenever the picker or hex input changes.
labelstringOptional field label rendered with the shared Label primitive.
withInputbooleantrueShows or hides the inline HexColorInput.
onBlur(color?: string | null) => voidCalled when the inline hex input loses focus.
disabledbooleanDisables the swatch trigger and input.
onClose(color?: string | null) => voidCalled when the popover closes.

Common Usage Patterns

Brand And Theme Settings

Use the default full control when users need to pick a color visually and verify the exact hex value.

This is the main settings-style usage:

  • visible label
  • swatch trigger
  • editable hex input
  • validation handled by the parent form

Dense Builder Controls

Use withInput={false} in tight control rows where the surrounding UI already provides enough context and the full text input would take too much space.

Inline Tag Or Category Creation

Use the compact swatch-only mode when color is secondary to a primary text field and should not dominate the form.

Brand Dashboard Usage Patterns

Representative usages:

PatternPathNotes
Brand appearance settingsfsai/apps/brand-dashboard/src/pages/BrandWorkspaceSettings/BrandAppearanceSettings/BrandAppearanceSettings.tsxCanonical labeled settings usage with react-hook-form, validation, reset, and save actions around the component.
Email builder style controlsfsai/apps/brand-dashboard/src/pages/EmailBuilder/EmailEditorSidebar/EmailEditorSidebar.components.tsxCompact builder usage with withInput={false} inside a dense control row.
Inline tagging formsfsai/apps/brand-dashboard/src/components/Tagging/Tagging.components.tsxShows the compact swatch-only pattern next to a text input in a small creation form.
Studio template editorsfsai/apps/brand-dashboard/src/pages/StudioEmailTemplates/StudioEmailTemplates.components.tsxAnother theme-editing style flow with multiple color fields.
QR template editorfsai/apps/brand-dashboard/src/pages/StudioQrTemplates/QrTemplateModal.tsxUses color picking in a richer template configuration modal.

Important Conventions

  • ColorInput is optimized for hex color editing, not arbitrary CSS color strings.
  • The visible text entry is optional; the popover picker is always driven by the swatch trigger.
  • Validation is usually handled by the parent form, not internally by ColorInput.
  • Use withInput={false} intentionally for dense UIs, not as the default in standard settings forms.
  • The component composes shared Label and Popover primitives rather than behaving like a plain native <input type="color">.

Guidelines

  • Do use ColorInput when users need both visual picking and explicit hex editing
  • Do keep the default input visible in settings-style forms
  • Do pair it with external validation when the stored value must be a valid hex color
  • Do use withInput={false} in tight toolbars, builders, or inline creation forms
  • Don't replace a normal text field with ColorInput unless the value is actually a user-facing color choice
  • Don't treat it like a generic design-token selector or theme system abstraction

On this page