Stroke picker
Colour, width, dash, ends and opacity of a line, with a live preview.
import { StrokePicker, editorDashArray, editorOpacityText } from "@forgeron/ui";import { StrokePicker, type EditorStroke } from "@forgeron/ui";
import { useState } from "react";
export default function Default() {
const [stroke, setStroke] = useState<EditorStroke>({
color: "#ff4f1f",
width: 4,
dash: "dashed",
cap: "round",
opacity: 0.9,
});
return (
<div style={{ width: "100%", maxWidth: 320 }}>
<StrokePicker label="Stroke" value={stroke} onChange={setStroke} />
</div>
);
}import { StrokePicker } from "@forgeron/ui";
export default function Fields() {
return (
<div style={{ width: "100%", maxWidth: 320 }}>
<StrokePicker label="Outline" fields={["color", "width"]} preview={false} />
</div>
);
}API → Props
| Prop | Type | Default | Description |
|---|---|---|---|
label | string | — | Names the panel: “Stroke”. |
value / defaultValue / onChange | { color: string | null, width, dash, cap, opacity } | — | dash: solid, dashed, dotted. cap: butt, round, square. opacity 0 to 1. A null colour is no line. |
fields | (“color” | “width” | “dash” | “cap” | “opacity”)[] | — | Which settings, in order. Default all five. |
maxWidth / preview | number; boolean | 32 / true | The widest line; the preview strip. |
disabled | boolean | — | Greys out the whole panel. |
className | string | — | Extra classes. |