Color picker
A swatch palette from the tokens and a hex field: no gradients, no sliders.
import { ColorPicker, COLOR_PALETTE } from "@forgeron/ui";import { ColorPicker } from "@forgeron/ui";
import { useState } from "react";
export default function Popup() {
const [color, setColor] = useState<string | null>("#ff4f1f");
return <ColorPicker label="Label colour" value={color} onChange={setColor} />;
}import { ColorPicker } from "@forgeron/ui";
export default function Inline() {
return <ColorPicker inline label="Project colour" columns={4} defaultValue="#3ddc84" />;
}API → Props
| Prop | Type | Default | Description |
|---|---|---|---|
label | string | — | Names the control for assistive technology. |
value / defaultValue | string | null | — | Controlled or not. #RRGGBB. |
onChange | (value: string | null) => void | — | On every change. |
palette | { value, label }[] | COLOR_PALETTE | The squares offered. |
hex | boolean | true | A field to type any code. |
clearable | boolean | true | Offers to remove the colour. |
inline | boolean | — | The palette in place, no button or popup. |
columns | number | 4 | Squares per row; arrows move in two dimensions. |
open / onOpenChange | boolean / (open) => void | — | Open it from outside. |
disabled | boolean | — | Not editable. |
className | string | — | Extra classes. |