EditableIconPickerField
EditableIconPickerField shows the currently selected icon as an 80×80 preview box in read mode. Clicking the edit icon renders the full IconPickerField browser, allowing the user to search and pick a new icon from the icon library. On save the icon name 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 | "" | Name of the currently selected icon. |
| updatePath | string | Yes | — | API endpoint path used to persist the change. |
| label | string | No | — | Label shown above the icon preview. |
| 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) => void | No | — | Called locally when the icon selection 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. |
Usage
Basic
import React, { useState } from 'react';
import EditableIconPickerField from '@/components/editable-fields/EditableIconPickerField';
export default function Example() {
const [icon, setIcon] = useState('star');
return (
<EditableIconPickerField
label="Action Icon"
name="icon"
value={icon}
updatePath="/v1/actions/14"
apiBaseUrl="https://api.example.com"
useAuthToken
onEditSuccess={(updated) => setIcon(updated)}
/>
);
}