Articles in this section

How to Add Custom Tooltip for Palette of JavaScript Diagram?

A tooltip is a text element that appears when a user hovers over an item, providing contextual information. In the JavaScript Diagram, tooltips can be shown on any diagram element such as nodes, connectors, or other components making it easy to convey additional information. Tooltips are also available in the SymbolPalette, where they appear when the mouse hovers over any symbol.

To set a custom description for tooltip in the SymbolPalette, use the node’s tooltip property. This allows you to display custom content instead of the default node ID. Set the desired text in the tooltip’s content property to customize the tooltip for each symbol. Ensure that Tooltip constraints are enabled in NodeConstraints for custom tooltips to appear.

The following code example demonstrates how to set a custom tooltip for symbols in the SymbolPalette:

   var basicShapes = [
       { id: 'Rectangle', shape: { type: 'Basic', shape: 'Rectangle' },
       tooltip:{
           content: 'Customized Tooltip',
       },
       // Enable customized tooltip to display on the symbol
       constraints:  ej.diagrams.NodeConstraints.Default |  ej.diagrams.NodeConstraints.Tooltip },
       { id: 'Ellipse', shape: { type: 'Basic', shape: 'Ellipse' },
       tooltip:{
           content: 'Customized Tooltip',
       },
       // Enable customized tooltip to display on the symbol
       constraints:  ej.diagrams.NodeConstraints.Default |  ej.diagrams.NodeConstraints.Tooltip },
   ];

   palettes: [
       { id: 'flow', expanded: true, symbols: flowshapes, iconCss: 'e-ddb-icons e-basic', title: 'Flow Shapes' },
       { id: 'basic', expanded: true, symbols: basicShapes, iconCss: 'e-ddb-icons e-flow', title: 'Basic Shapes' },
   ],

In this example, a custom tooltip is set for basic shapes. Please refer to the working sample for reference.

Sample

Conclusion

I hope you enjoyed learning how to add custom tooltips for the palette of the JavaScript Diagram.
You can refer to our JavaScript 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 JavaScript 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 check out 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, Direct-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Access denied
Access denied