/v1.0

EditableColorPaletteField

EditableColorPaletteField is a simplified color picker that restricts selection to a curated set of 13 pastel/vivid circular swatches. In read mode the selected color is displayed as an 80×80 rounded swatch. Clicking the edit icon enables the swatch; tapping on it opens a popover with the fixed palette. Tapping a selected color clears it. On save the hex color string is persisted via API.

Props

| Prop | Type | Required | Default | Description | |------|------|----------|---------|-------------| | name | string | Yes | — | Field name sent as the key in the update payload. | | value | string | Yes | "" | Current color value as a hex string (e.g. "#A597CC"). | | updatePath | string | Yes | — | API endpoint path used to persist the change. | | label | string | No | — | Label shown above the swatch. | | description | string | No | — | Helper text shown below the label. | | apiBaseUrl | string | No | — | Base URL prepended to updatePath. | | useAuthToken | boolean | No | false | When true, the request includes the authorization token. | | onChange | (newValue?: string \| null) => void | No | — | Called locally whenever the color changes. | | onEditStart | () => void | No | — | Called when edit mode begins. | | onEditSuccess | (updatedValue: string, newFormData: any) => void | No | — | Called after successful save. | | onEditError | (error: any) => void | No | — | Called on API error; value is reverted. | | onEditCancel | () => void | No | — | Called when the user cancels; value is reverted. | | editIcon | string | No | "pencil" | Icon name for the edit button. | | saveIcon | string | No | "check" | Icon name for the save button. | | cancelIcon | string | No | "close" | Icon name for the cancel button. | | containerStyle | React.CSSProperties | No | — | Style for the outermost wrapper. | | inputStyle | React.CSSProperties | No | — | Style for the inner input element. | | labelStyle | React.CSSProperties | No | — | Style for the <label> element. | | descriptionStyle | React.CSSProperties | No | — | Style for the description <p> element. | | headerStyle | React.CSSProperties | No | — | Style for the FieldContainer header. | | bodyStyle | React.CSSProperties | No | — | Style for the body wrapping the swatch. |

Usage

Basic

import React, { useState } from 'react';
import EditableColorPaletteField from '@/components/editable-fields/EditableColorPaletteField';

export default function Example() {
  const [tagColor, setTagColor] = useState('#94B7DF');

  return (
    <EditableColorPaletteField
      label="Tag Color"
      name="tag_color"
      value={tagColor}
      updatePath="/v1/tags/5"
      apiBaseUrl="https://api.example.com"
      useAuthToken
      onEditSuccess={(updated) => setTagColor(updated)}
    />
  );
}