How to Customize Shape Colors Using Color Picker in React Diagram?
This article explains how to customize shape colors using a color picker in React Diagram. To customize the color of shapes in the React Diagram, you can use the fill property of shapes. This property allows you to set the color of shapes in the diagram.
Refer to the code snippet below to customize the color of nodes using the fill property:
// Set fill property to customize the color of nodes
var nodes = [
{
id:'node1',
offsetX: 250,
offsetY: 250,
width: 100,
height: 100,
style: {fill:'white'}
}
];
To dynamically customize the color of shapes in your diagram, you can use the color picker component React ColorPicker. The color picker allows users to select a color, which is then applied to the fill property of the shapes in the diagram. This updates the color of the shapes in real-time, providing a smooth and interactive way to customize the appearance of elements in your diagram.
Refer to the code snippet below to customize the color of shapes:
import { ColorPickerComponent} from "@syncfusion/ej2-react-inputs";
function renderFontColorPicker() {
return (
<div className="col-xs-4 column-style">
<ColorPickerComponent
id="fontcolor"
showButtons={false}
mode="Palette"
change={(arg) => {
diagramInstance.selectedItems.nodes.forEach((node) => {
node.style.fill = arg.currentValue.rgba;
});
diagramInstance.dataBind();
}}
ref={(fontcolor) => (fontColor = fontcolor)}
/>
</div>
);
}
Refer to the working sample for additional details and implementation: click here for sample
Conclusion
We hope you enjoyed learning how to customize shape Colors using Color Picker in React Diagram.
You can refer to our React Diagram feature tour page to learn about its other groundbreaking feature representations and documentation, and how to quickly get started with configuration specifications. You can also explore our React Diagram example to understand how to create and manipulate data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to explore our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, BoldDesk Support, or feedback portal. We are always happy to assist you!