Blocks / Fill picker

Fill picker

None, a solid colour or a dither pattern, with opacity.

import { FillPicker, PatternSwatch, EDITOR_FILL_PATTERNS, editorPatternCells } from "@forgeron/ui";
/01 → Default
Fill
Fill opacity100%
import { FillPicker, type EditorFill } from "@forgeron/ui";
import { useState } from "react";

export default function Default() {
  const [fill, setFill] = useState<EditorFill>({
    type: "pattern",
    pattern: "hatch",
    color: "#ff4f1f",
  });
  return (
    <div style={{ width: "100%", maxWidth: 320 }}>
      <FillPicker label="Fill" value={fill} onChange={setFill} />
    </div>
  );
}
API → Props
PropTypeDefaultDescription
labelstring—Names the panel: “Fill”.
value / defaultValue / onChange{ type: “none” } | { type: “solid”, color, opacity? } | { type: “pattern”, pattern, color, opacity? }—A fill. Switching kind keeps the last colour.
patternsstring[]—Pattern ids offered (dots-25, dots-50, dots-75, lines-h, lines-v, hatch, hatch-back, cross). Empty hides the Pattern tab.
opacitybooleantrueThe opacity slider.
disabledboolean—Greys out the whole panel.
classNamestring—Extra classes.