Tooltip in EJ2 React Diagram component

27 Oct 202424 minutes to read

In a Graphical User Interface (GUI), a tooltip is a message that appears when the mouse hovers over an element. The diagram control provides tooltip support while dragging, resizing, rotating a node, and when the mouse hovers over any diagram element.

Default tooltip

By default, the diagram displays a tooltip showing size, position, and angle information while dragging, resizing, or rotating a node. The following images illustrate how the diagram displays node information during these interactions.

Drag Resize Rotate
ToolTip During Drag ToolTip During Resize ToolTip During Rotate

Disable default tooltip

The default tooltip that appears while interacting with nodes can be disabled by removing the tooltip constraints from the selectorConstraints of the selectedItems property of the diagram.

import * as React from "react";
import * as ReactDOM from "react-dom";
import { DiagramComponent, SelectorConstraints } from "@syncfusion/ej2-react-diagrams";
// A node is created and stored in nodes array.
let node = [{
        id: "node1",
        width: 100,
        height: 100,
        annotations: [{
                id: 'label',
                content: 'Default tooltip disabled',
                offset: {
                    x: 0.5,
                    y: 0.5
                },
                style: {
                    color: 'white',
                },
            }],
        offsetX: 200,
        offsetY: 200,
        style: {
            strokeColor: '#6BA5D7',
            fill: '#6BA5D7',
        },
       
    }];
//Initializes the Diagram component
function App() {
    return (<DiagramComponent id="container" width={'650px'} height={'350px'} 
    selectedItems=
    //Defines nodes
    nodes={node} 
    //Defines mouse over tooltip
    tooltip=<h1 id="tooltip-in-react-rating-component">Tooltip in React Rating Component</h1>

<p>The rating component supports tooltip to show additional information in rating items by setting the <a href="https://ej2.syncfusion.com/react/documentation/api/rating/#showtooltip"><code>showTooltip</code></a> property. If enabled, the tooltip appears when the user hovers over a rating item.</p>

<div class="tabs" id="code-snippet-1">

<ul class="nav nav-tabs" role="tablist">

<li role="presentation" class=""><a data-target="#dl6n7q0wcfe3woaocdpcs4eeubtvccyp-js" aria-controls="home" role="tab" data-toggle="tab" data-original-lang="js">index.jsx</a></li>
<li role="presentation" class=""><a data-target="#tusza991sr0e577o4xm26tri68d612h3-ts" aria-controls="home" role="tab" data-toggle="tab" data-original-lang="ts">index.tsx</a></li>

</ul>

<div class="tab-content">


<div role="tabpanel" class="tab-pane" id="dl6n7q0wcfe3woaocdpcs4eeubtvccyp-js" data-original-lang="js">
<div class="highlight"><pre><code class="prettyprint language-js" data-lang="js"><span></span><span class="c1">// Import the Rating.</span>
<span class="k">import</span> <span class="p">{</span> <span class="nx">RatingComponent</span> <span class="p">}</span> <span class="kr">from</span> <span class="s1">'@syncfusion/ej2-react-inputs'</span><span class="p">;</span>
<span class="k">import</span> <span class="o">*</span> <span class="kr">as</span> <span class="nx">React</span> <span class="kr">from</span> <span class="s1">'react'</span><span class="p">;</span>
<span class="k">import</span> <span class="o">*</span> <span class="kr">as</span> <span class="nx">ReactDom</span> <span class="kr">from</span> <span class="s1">'react-dom'</span><span class="p">;</span>
<span class="c1">// To render Rating.</span>
<span class="kd">function</span> <span class="nx">App</span><span class="p">()</span> <span class="p">{</span>
    <span class="k">return</span> <span class="p">(</span><span class="o">&lt;</span><span class="nx">div</span> <span class="nx">className</span><span class="o">=</span><span class="s1">'wrap'</span><span class="o">&gt;</span>
            <span class="o">&lt;</span><span class="nx">RatingComponent</span> <span class="nx">id</span><span class="o">=</span><span class="s1">'rating'</span> <span class="nx">showTooltip</span><span class="o">=</span><span class="p">{</span><span class="kc">true</span><span class="p">}</span> <span class="nx">value</span><span class="o">=</span><span class="p">{</span><span class="mf">3</span><span class="p">}</span><span class="o">&gt;&lt;</span><span class="err">/RatingComponent&gt;</span>
        <span class="o">&lt;</span><span class="err">/div&gt;);</span>
<span class="p">}</span>
<span class="k">export</span> <span class="k">default</span> <span class="nx">App</span><span class="p">;</span>
<span class="nx">ReactDom</span><span class="p">.</span><span class="nx">render</span><span class="p">(</span><span class="o">&lt;</span><span class="nx">App</span> <span class="o">/&gt;</span><span class="p">,</span> <span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="s1">'element'</span><span class="p">));</span></code></pre></div>
</div>

<div role="tabpanel" class="tab-pane" id="tusza991sr0e577o4xm26tri68d612h3-ts" data-original-lang="ts">
<div class="highlight"><pre><code class="prettyprint language-ts" data-lang="ts"><span></span><span class="c1">// Import the Rating.</span>
<span class="k">import</span> <span class="p">{</span> <span class="nx">RatingComponent</span> <span class="p">}</span> <span class="kr">from</span> <span class="s1">'@syncfusion/ej2-react-inputs'</span><span class="p">;</span>
<span class="k">import</span> <span class="o">*</span> <span class="kr">as</span> <span class="nx">React</span> <span class="kr">from</span> <span class="s1">'react'</span><span class="p">;</span>
<span class="k">import</span> <span class="o">*</span> <span class="kr">as</span> <span class="nx">ReactDom</span> <span class="kr">from</span> <span class="s1">'react-dom'</span><span class="p">;</span>

<span class="c1">// To render Rating.</span>
<span class="kd">function</span> <span class="nx">App</span><span class="p">()</span> <span class="p">{</span>
  
    <span class="k">return</span> <span class="p">(</span>
        <span class="o">&lt;</span><span class="nx">div</span> <span class="nx">className</span><span class="o">=</span><span class="s1">'wrap'</span><span class="o">&gt;</span>
            <span class="o">&lt;</span><span class="nx">RatingComponent</span> <span class="nx">id</span><span class="o">=</span><span class="s1">'rating'</span> <span class="nx">showTooltip</span><span class="o">=</span><span class="p">{</span><span class="kc">true</span><span class="p">}</span> <span class="nx">value</span><span class="o">=</span><span class="p">{</span><span class="mf">3</span><span class="p">}</span> <span class="o">&gt;&lt;</span><span class="err">/RatingComponent&gt;</span>
        <span class="o">&lt;</span><span class="err">/div&gt;</span>
    <span class="p">);</span>
<span class="p">}</span>
<span class="k">export</span> <span class="k">default</span> <span class="nx">App</span><span class="p">;</span>
<span class="nx">ReactDom</span><span class="p">.</span><span class="nx">render</span><span class="p">(</span><span class="o">&lt;</span><span class="nx">App</span> <span class="o">/&gt;</span><span class="p">,</span><span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="s1">'element'</span><span class="p">));</span></code></pre></div>
</div>

</div>

</div>

<p><button class="preview-sample-button" id="PreviewSampleButton-e3g1gt0u2ngxfewkudkqwdg8zoe3grie" onclick="LoadPreviewSample('https://ej2.syncfusion.com/react/documentation/code-snippet/rating/tooltip/showtooltip-cs1',this.id);">Preview Sample</button><button class="stackblitz-button" id="StackBlitzButton-e3g1gt0u2ngxfewkudkqwdg8zoe3grie" onclick="OpenSampleInStackBlitz('https://ej2.syncfusion.com/react/documentation/code-snippet/rating/tooltip/showtooltip-cs1');"><img class="stackblitz-icon" src="https://cdn.syncfusion.com/documentation/images/StackBlitz-icon.png"><span class="stackblitz-text">Open in Stackblitz</span></button></p>
<div id="PreviewSampleHolder-e3g1gt0u2ngxfewkudkqwdg8zoe3grie"></div>

<h2 id="tooltip-template">Tooltip template</h2>

<p>You can use the <a href="https://ej2.syncfusion.com/react/documentation/api/rating/#tooltiptemplate"><code>tooltipTemplate</code></a> tag directive to specify a custom template for the <code>tooltip</code> of the rating. The current value of the rating will be passed as the <code>value</code> property in the template context when building the content of the tooltip. This allows you to include dynamic information about the rating in the template.</p>

<div class="tabs" id="code-snippet-2">

<ul class="nav nav-tabs" role="tablist">

<li role="presentation" class=""><a data-target="#v32y668atapfui31ufmv4kqjutfnni84-js" aria-controls="home" role="tab" data-toggle="tab" data-original-lang="js">index.jsx</a></li>
<li role="presentation" class=""><a data-target="#8k84637upqqbghwln32l3m2f01jvj1fg-ts" aria-controls="home" role="tab" data-toggle="tab" data-original-lang="ts">index.tsx</a></li>

</ul>

<div class="tab-content">


<div role="tabpanel" class="tab-pane" id="v32y668atapfui31ufmv4kqjutfnni84-js" data-original-lang="js">
<div class="highlight"><pre><code class="prettyprint language-js" data-lang="js"><span></span><span class="c1">// Import the Rating.</span>
<span class="k">import</span> <span class="p">{</span> <span class="nx">RatingComponent</span> <span class="p">}</span> <span class="kr">from</span> <span class="s1">'@syncfusion/ej2-react-inputs'</span><span class="p">;</span>
<span class="k">import</span> <span class="o">*</span> <span class="kr">as</span> <span class="nx">React</span> <span class="kr">from</span> <span class="s1">'react'</span><span class="p">;</span>
<span class="k">import</span> <span class="o">*</span> <span class="kr">as</span> <span class="nx">ReactDom</span> <span class="kr">from</span> <span class="s1">'react-dom'</span><span class="p">;</span>
<span class="c1">// To render Rating.</span>
<span class="kd">function</span> <span class="nx">App</span><span class="p">()</span> <span class="p">{</span>
    <span class="kd">function</span> <span class="nx">tooltipTemplate</span><span class="p">(</span><span class="nx">props</span><span class="p">)</span> <span class="p">{</span>
        <span class="k">if</span> <span class="p">(</span><span class="nx">props</span><span class="p">.</span><span class="nx">value</span> <span class="o">===</span> <span class="mf">1</span><span class="p">)</span> <span class="p">{</span>
            <span class="k">return</span> <span class="p">(</span><span class="o">&lt;</span><span class="nx">b</span><span class="o">&gt;</span><span class="nx">Angry</span><span class="o">&lt;</span><span class="err">/b&gt;);</span>
        <span class="p">}</span>
        <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="nx">props</span><span class="p">.</span><span class="nx">value</span> <span class="o">===</span> <span class="mf">2</span><span class="p">)</span> <span class="p">{</span>
            <span class="k">return</span> <span class="p">(</span><span class="o">&lt;</span><span class="nx">b</span><span class="o">&gt;</span><span class="nx">Sad</span><span class="o">&lt;</span><span class="err">/b&gt;);</span>
        <span class="p">}</span>
        <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="nx">props</span><span class="p">.</span><span class="nx">value</span> <span class="o">===</span> <span class="mf">3</span><span class="p">)</span> <span class="p">{</span>
            <span class="k">return</span> <span class="p">(</span><span class="o">&lt;</span><span class="nx">b</span><span class="o">&gt;</span><span class="nx">Neutral</span><span class="o">&lt;</span><span class="err">/b&gt;);</span>
        <span class="p">}</span>
        <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="nx">props</span><span class="p">.</span><span class="nx">value</span> <span class="o">===</span> <span class="mf">4</span><span class="p">)</span> <span class="p">{</span>
            <span class="k">return</span> <span class="p">(</span><span class="o">&lt;</span><span class="nx">b</span><span class="o">&gt;</span><span class="nx">Good</span><span class="o">&lt;</span><span class="err">/b&gt;);</span>
        <span class="p">}</span>
        <span class="k">else</span> <span class="p">{</span>
            <span class="k">return</span> <span class="p">(</span><span class="o">&lt;</span><span class="nx">b</span><span class="o">&gt;</span><span class="nx">Happy</span><span class="o">&lt;</span><span class="err">/b&gt;);</span>
        <span class="p">}</span>
    <span class="p">}</span>
    <span class="k">return</span> <span class="p">(</span><span class="o">&lt;</span><span class="nx">div</span> <span class="nx">className</span><span class="o">=</span><span class="s1">'wrap'</span><span class="o">&gt;</span>
          <span class="o">&lt;</span><span class="nx">RatingComponent</span> <span class="nx">id</span><span class="o">=</span><span class="s1">'rating'</span> <span class="nx">showTooltip</span><span class="o">=</span><span class="p">{</span><span class="kc">true</span><span class="p">}</span> <span class="nx">value</span><span class="o">=</span><span class="p">{</span><span class="mf">3</span><span class="p">}</span> <span class="nx">tooltipTemplate</span><span class="o">=</span><span class="p">{</span><span class="nx">tooltipTemplate</span><span class="p">}</span><span class="o">&gt;&lt;</span><span class="err">/RatingComponent&gt;</span>
      <span class="o">&lt;</span><span class="err">/div&gt;);</span>
<span class="p">}</span>
<span class="k">export</span> <span class="k">default</span> <span class="nx">App</span><span class="p">;</span>
<span class="nx">ReactDom</span><span class="p">.</span><span class="nx">render</span><span class="p">(</span><span class="o">&lt;</span><span class="nx">App</span> <span class="o">/&gt;</span><span class="p">,</span> <span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="s1">'element'</span><span class="p">));</span></code></pre></div>
</div>

<div role="tabpanel" class="tab-pane" id="8k84637upqqbghwln32l3m2f01jvj1fg-ts" data-original-lang="ts">
<div class="highlight"><pre><code class="prettyprint language-ts" data-lang="ts"><span></span><span class="c1">// Import the Rating.</span>
<span class="k">import</span> <span class="p">{</span> <span class="nx">RatingComponent</span> <span class="p">}</span> <span class="kr">from</span> <span class="s1">'@syncfusion/ej2-react-inputs'</span><span class="p">;</span>
<span class="k">import</span> <span class="o">*</span> <span class="kr">as</span> <span class="nx">React</span> <span class="kr">from</span> <span class="s1">'react'</span><span class="p">;</span>
<span class="k">import</span> <span class="o">*</span> <span class="kr">as</span> <span class="nx">ReactDom</span> <span class="kr">from</span> <span class="s1">'react-dom'</span><span class="p">;</span>

<span class="c1">// To render Rating.</span>
<span class="kd">function</span> <span class="nx">App</span><span class="p">()</span> <span class="p">{</span>

    <span class="kd">function</span> <span class="nx">tooltipTemplate</span><span class="p">(</span><span class="nx">props</span>: <span class="kt">any</span><span class="p">)</span> <span class="p">{</span>
        <span class="k">if</span><span class="p">(</span><span class="nx">props</span><span class="p">.</span><span class="nx">value</span> <span class="o">===</span> <span class="mf">1</span><span class="p">){</span>
            <span class="k">return</span> <span class="p">(</span><span class="o">&lt;</span><span class="nx">b</span><span class="o">&gt;</span><span class="nx">Angry</span><span class="o">&lt;</span><span class="err">/b&gt;);}</span>
        <span class="k">else</span> <span class="k">if</span><span class="p">(</span><span class="nx">props</span><span class="p">.</span><span class="nx">value</span> <span class="o">===</span> <span class="mf">2</span><span class="p">){</span>
            <span class="k">return</span> <span class="p">(</span><span class="o">&lt;</span><span class="nx">b</span><span class="o">&gt;</span><span class="nx">Sad</span><span class="o">&lt;</span><span class="err">/b&gt;);}</span>
        <span class="k">else</span> <span class="k">if</span><span class="p">(</span><span class="nx">props</span><span class="p">.</span><span class="nx">value</span> <span class="o">===</span> <span class="mf">3</span><span class="p">){</span>
            <span class="k">return</span> <span class="p">(</span><span class="o">&lt;</span><span class="nx">b</span><span class="o">&gt;</span><span class="nx">Neutral</span><span class="o">&lt;</span><span class="err">/b&gt;);}</span>
        <span class="k">else</span> <span class="k">if</span><span class="p">(</span><span class="nx">props</span><span class="p">.</span><span class="nx">value</span> <span class="o">===</span> <span class="mf">4</span><span class="p">){</span>
            <span class="k">return</span> <span class="p">(</span><span class="o">&lt;</span><span class="nx">b</span><span class="o">&gt;</span><span class="nx">Good</span><span class="o">&lt;</span><span class="err">/b&gt;);}</span>
        <span class="k">else</span> <span class="p">{</span>
            <span class="k">return</span> <span class="p">(</span><span class="o">&lt;</span><span class="nx">b</span><span class="o">&gt;</span><span class="nx">Happy</span><span class="o">&lt;</span><span class="err">/b&gt;);}</span>
    <span class="p">}</span>
  
    <span class="k">return</span> <span class="p">(</span>
        <span class="o">&lt;</span><span class="nx">div</span> <span class="nx">className</span><span class="o">=</span><span class="s1">'wrap'</span><span class="o">&gt;</span>
            <span class="o">&lt;</span><span class="nx">RatingComponent</span> <span class="nx">id</span><span class="o">=</span><span class="s1">'rating'</span> <span class="nx">showTooltip</span><span class="o">=</span><span class="p">{</span><span class="kc">true</span><span class="p">}</span> <span class="nx">value</span><span class="o">=</span><span class="p">{</span><span class="mf">3</span><span class="p">}</span> <span class="nx">tooltipTemplate</span><span class="o">=</span><span class="p">{</span><span class="nx">tooltipTemplate</span><span class="p">}</span> <span class="o">&gt;&lt;</span><span class="err">/RatingComponent&gt;</span>
        <span class="o">&lt;</span><span class="err">/div&gt;</span>
    <span class="p">);</span>
<span class="p">}</span>
<span class="k">export</span> <span class="k">default</span> <span class="nx">App</span><span class="p">;</span>
<span class="nx">ReactDom</span><span class="p">.</span><span class="nx">render</span><span class="p">(</span><span class="o">&lt;</span><span class="nx">App</span> <span class="o">/&gt;</span><span class="p">,</span><span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="s1">'element'</span><span class="p">));</span></code></pre></div>
</div>

</div>

</div>

<p><button class="preview-sample-button" id="PreviewSampleButton-rks1aag7xch7axcvy1s11f80vy7hlu0c" onclick="LoadPreviewSample('https://ej2.syncfusion.com/react/documentation/code-snippet/rating/tooltip/tooltip-template-cs1',this.id);">Preview Sample</button><button class="stackblitz-button" id="StackBlitzButton-rks1aag7xch7axcvy1s11f80vy7hlu0c" onclick="OpenSampleInStackBlitz('https://ej2.syncfusion.com/react/documentation/code-snippet/rating/tooltip/tooltip-template-cs1');"><img class="stackblitz-icon" src="https://cdn.syncfusion.com/documentation/images/StackBlitz-icon.png"><span class="stackblitz-text">Open in Stackblitz</span></button></p>
<div id="PreviewSampleHolder-rks1aag7xch7axcvy1s11f80vy7hlu0c"></div>

<h2 id="tooltip-customization">Tooltip customization</h2>

<p>You can customize the appearance of the tooltips using the <code>cssClass</code> property of the rating component and by defining the custom styles for tooltip elements like the below example.</p>

<blockquote>
  <p>You can find more information about customizing the appearance of the tooltip in the <a href="https://ej2.syncfusion.com/react/documentation/tooltip/style/">Tooltip Customization</a> documentation.</p>
</blockquote>

<div class="tabs" id="code-snippet-3">

<ul class="nav nav-tabs" role="tablist">

<li role="presentation" class=""><a data-target="#2bwj3rbta2k6j07fyg97q3kp9uu4l1f3-js" aria-controls="home" role="tab" data-toggle="tab" data-original-lang="js">index.jsx</a></li>
<li role="presentation" class=""><a data-target="#pyrpw0fzkuci9lbs9gdb2wtvnm3m6hio-ts" aria-controls="home" role="tab" data-toggle="tab" data-original-lang="ts">index.tsx</a></li>
<li role="presentation" class=""><a data-target="#8maqbq35304e8d1c9gihyflcyj827o90-ts" aria-controls="home" role="tab" data-toggle="tab" data-original-lang="ts">styles.css</a></li>

</ul>

<div class="tab-content">


<div role="tabpanel" class="tab-pane" id="2bwj3rbta2k6j07fyg97q3kp9uu4l1f3-js" data-original-lang="js">
<div class="highlight"><pre><code class="prettyprint language-js" data-lang="js"><span></span><span class="c1">// Import the Rating.</span>
<span class="k">import</span> <span class="p">{</span> <span class="nx">RatingComponent</span> <span class="p">}</span> <span class="kr">from</span> <span class="s1">'@syncfusion/ej2-react-inputs'</span><span class="p">;</span>
<span class="k">import</span> <span class="o">*</span> <span class="kr">as</span> <span class="nx">React</span> <span class="kr">from</span> <span class="s1">'react'</span><span class="p">;</span>
<span class="k">import</span> <span class="o">*</span> <span class="kr">as</span> <span class="nx">ReactDom</span> <span class="kr">from</span> <span class="s1">'react-dom'</span><span class="p">;</span>
<span class="c1">// To render Rating.</span>
<span class="kd">function</span> <span class="nx">App</span><span class="p">()</span> <span class="p">{</span>
    <span class="k">return</span> <span class="p">(</span><span class="o">&lt;</span><span class="nx">div</span> <span class="nx">className</span><span class="o">=</span><span class="s1">'wrap'</span><span class="o">&gt;</span>
          <span class="o">&lt;</span><span class="nx">RatingComponent</span> <span class="nx">id</span><span class="o">=</span><span class="s1">'rating'</span> <span class="nx">showTooltip</span><span class="o">=</span><span class="p">{</span><span class="kc">true</span><span class="p">}</span> <span class="nx">value</span><span class="o">=</span><span class="p">{</span><span class="mf">3</span><span class="p">}</span> <span class="nx">cssClass</span><span class="o">=</span><span class="s1">'customtooltip'</span><span class="o">&gt;&lt;</span><span class="err">/RatingComponent&gt;</span>
      <span class="o">&lt;</span><span class="err">/div&gt;);</span>
<span class="p">}</span>
<span class="k">export</span> <span class="k">default</span> <span class="nx">App</span><span class="p">;</span>
<span class="nx">ReactDom</span><span class="p">.</span><span class="nx">render</span><span class="p">(</span><span class="o">&lt;</span><span class="nx">App</span> <span class="o">/&gt;</span><span class="p">,</span> <span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="s1">'element'</span><span class="p">));</span></code></pre></div>
</div>

<div role="tabpanel" class="tab-pane" id="pyrpw0fzkuci9lbs9gdb2wtvnm3m6hio-ts" data-original-lang="ts">
<div class="highlight"><pre><code class="prettyprint language-ts" data-lang="ts"><span></span><span class="c1">// Import the Rating.</span>
<span class="k">import</span> <span class="p">{</span> <span class="nx">RatingComponent</span> <span class="p">}</span> <span class="kr">from</span> <span class="s1">'@syncfusion/ej2-react-inputs'</span><span class="p">;</span>
<span class="k">import</span> <span class="o">*</span> <span class="kr">as</span> <span class="nx">React</span> <span class="kr">from</span> <span class="s1">'react'</span><span class="p">;</span>
<span class="k">import</span> <span class="o">*</span> <span class="kr">as</span> <span class="nx">ReactDom</span> <span class="kr">from</span> <span class="s1">'react-dom'</span><span class="p">;</span>

<span class="c1">// To render Rating.</span>
<span class="kd">function</span> <span class="nx">App</span><span class="p">()</span> <span class="p">{</span>
  
    <span class="k">return</span> <span class="p">(</span>
        <span class="o">&lt;</span><span class="nx">div</span> <span class="nx">className</span><span class="o">=</span><span class="s1">'wrap'</span><span class="o">&gt;</span>
            <span class="o">&lt;</span><span class="nx">RatingComponent</span> <span class="nx">id</span><span class="o">=</span><span class="s1">'rating'</span> <span class="nx">showTooltip</span><span class="o">=</span><span class="p">{</span><span class="kc">true</span><span class="p">}</span> <span class="nx">value</span><span class="o">=</span><span class="p">{</span><span class="mf">3</span><span class="p">}</span> <span class="nx">cssClass</span><span class="o">=</span><span class="s1">'customtooltip'</span> <span class="o">&gt;&lt;</span><span class="err">/RatingComponent&gt;</span>
        <span class="o">&lt;</span><span class="err">/div&gt;</span>
    <span class="p">);</span>
<span class="p">}</span>
<span class="k">export</span> <span class="k">default</span> <span class="nx">App</span><span class="p">;</span>
<span class="nx">ReactDom</span><span class="p">.</span><span class="nx">render</span><span class="p">(</span><span class="o">&lt;</span><span class="nx">App</span> <span class="o">/&gt;</span><span class="p">,</span><span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="s1">'element'</span><span class="p">));</span></code></pre></div>
</div>

<div role="tabpanel" class="tab-pane" id="8maqbq35304e8d1c9gihyflcyj827o90-ts" data-original-lang="ts">
<div class="highlight"><pre><code class="prettyprint language-ts" data-lang="ts"><span></span><span class="cm">/* Represents the styles for loader */</span>
<span class="err">#</span><span class="nx">loader</span> <span class="p">{</span>
    <span class="nx">color</span><span class="o">:</span> <span class="err">#</span><span class="mo">00</span><span class="mf">8</span><span class="nx">cff</span><span class="p">;</span>
    <span class="nx">font</span><span class="o">-</span><span class="nx">family</span><span class="o">:</span> <span class="s1">'Helvetica Neue'</span><span class="p">,</span> <span class="s1">'calibiri'</span><span class="p">;</span>
    <span class="nx">font</span><span class="o">-</span><span class="nx">size</span>: <span class="kt">14px</span><span class="p">;</span>
    <span class="nx">height</span>: <span class="kt">40px</span><span class="p">;</span>
    <span class="nx">left</span>: <span class="kt">45</span><span class="o">%</span><span class="p">;</span>
    <span class="nx">position</span>: <span class="kt">absolute</span><span class="p">;</span>
    <span class="nx">top</span>: <span class="kt">45</span><span class="o">%</span><span class="p">;</span>
    <span class="nx">width</span>: <span class="kt">30</span><span class="o">%</span><span class="p">;</span>
<span class="p">}</span>

<span class="p">.</span><span class="nx">wrap</span> <span class="p">{</span>
    <span class="nx">margin</span>: <span class="kt">50px</span> <span class="nx">auto</span><span class="p">;</span>
    <span class="nx">text</span><span class="o">-</span><span class="nx">align</span>: <span class="kt">center</span><span class="p">;</span>
<span class="p">}</span>

<span class="cm">/* To change the radius of the tooltip corners. */</span>
<span class="p">.</span><span class="nx">customtooltip</span><span class="p">.</span><span class="nx">e</span><span class="o">-</span><span class="nx">tooltip</span><span class="o">-</span><span class="nx">wrap</span> <span class="p">{</span>
  <span class="nx">border</span><span class="o">-</span><span class="nx">radius</span>: <span class="kt">3px</span><span class="p">;</span>
<span class="p">}</span>

<span class="cm">/* To change the size of the tooltip content. */</span>
<span class="p">.</span><span class="nx">customtooltip</span><span class="p">.</span><span class="nx">e</span><span class="o">-</span><span class="nx">tooltip</span><span class="o">-</span><span class="nx">wrap</span> <span class="p">.</span><span class="nx">e</span><span class="o">-</span><span class="nx">tip</span><span class="o">-</span><span class="nx">content</span> <span class="p">{</span>
  <span class="nx">font</span><span class="o">-</span><span class="nx">size</span>:<span class="kt">14px</span><span class="p">;</span>
<span class="p">}</span>

<span class="cm">/* To change the border color and width for tooltip. */</span>
<span class="p">.</span><span class="nx">customtooltip</span><span class="p">.</span><span class="nx">e</span><span class="o">-</span><span class="nx">tooltip</span><span class="o">-</span><span class="nx">wrap</span><span class="p">.</span><span class="nx">e</span><span class="o">-</span><span class="nx">popup</span> <span class="p">{</span>
  <span class="nx">border</span>: <span class="kt">2px</span> <span class="nx">solid</span> <span class="err">#</span><span class="mo">000000</span><span class="p">;</span>
<span class="p">}</span>

<span class="cm">/* To change the color for arrow of the tooltip. */</span>
<span class="p">.</span><span class="nx">customtooltip</span><span class="p">.</span><span class="nx">e</span><span class="o">-</span><span class="nx">tooltip</span><span class="o">-</span><span class="nx">wrap</span> <span class="p">.</span><span class="nx">e</span><span class="o">-</span><span class="nx">arrow</span><span class="o">-</span><span class="nx">tip</span><span class="o">-</span><span class="nx">inner</span><span class="p">.</span><span class="nx">e</span><span class="o">-</span><span class="nx">tip</span><span class="o">-</span><span class="nx">bottom</span> <span class="p">{</span>
  <span class="nx">border</span>: <span class="kt">12px</span> <span class="err">#</span><span class="mf">9693</span>
<span class="p">}</span>

<span class="cm">/* To change the top border color for arrow of the tooltip. */</span>
<span class="p">.</span><span class="nx">customtooltip</span><span class="p">.</span><span class="nx">e</span><span class="o">-</span><span class="nx">tooltip</span><span class="o">-</span><span class="nx">wrap</span> <span class="p">.</span><span class="nx">e</span><span class="o">-</span><span class="nx">arrow</span><span class="o">-</span><span class="nx">tip</span><span class="o">-</span><span class="nx">outer</span><span class="p">.</span><span class="nx">e</span><span class="o">-</span><span class="nx">tip</span><span class="o">-</span><span class="nx">bottom</span> <span class="p">{</span>
  <span class="nx">border</span><span class="o">-</span><span class="nx">top</span>: <span class="kt">9.5px</span> <span class="nx">solid</span> <span class="err">#</span><span class="mo">000000</span><span class="p">;</span>
<span class="p">}</span></code></pre></div>
</div>

</div>

</div>

<p><button class="preview-sample-button" id="PreviewSampleButton-q43a5q9g041jvllkj3afg6a1zjvivnip" onclick="LoadPreviewSample('https://ej2.syncfusion.com/react/documentation/code-snippet/rating/tooltip/custom-tooltip-cs1',this.id);">Preview Sample</button><button class="stackblitz-button" id="StackBlitzButton-q43a5q9g041jvllkj3afg6a1zjvivnip" onclick="OpenSampleInStackBlitz('https://ej2.syncfusion.com/react/documentation/code-snippet/rating/tooltip/custom-tooltip-cs1');"><img class="stackblitz-icon" src="https://cdn.syncfusion.com/documentation/images/StackBlitz-icon.png"><span class="stackblitz-text">Open in Stackblitz</span></button></p>
<div id="PreviewSampleHolder-q43a5q9g041jvllkj3afg6a1zjvivnip"></div>
/>);
}
const root = ReactDOM.createRoot(document.getElementById('diagram'));
root.render(<App />);
import * as React from "react";
import * as ReactDOM from "react-dom";
import { DiagramComponent, SelectorConstraints,NodeModel } from "@syncfusion/ej2-react-diagrams";
// A node is created and stored in nodes array.
let node:NodeModel[] = [{
        id: "node1",
        width: 100,
        height: 100,
        annotations: [{
                id: 'label',
                content: 'Default tooltip disabled',
                offset: {
                    x: 0.5,
                    y: 0.5
                },
                style: {
                    color: 'white',
                },
            }],
        offsetX: 200,
        offsetY: 200,
        style: {
            strokeColor: '#6BA5D7',
            fill: '#6BA5D7',
        },
       
    }];
//Initializes the Diagram component
function App() {
    return (<DiagramComponent id="container" width={'650px'} height={'350px'} 
    selectedItems=
    //Defines nodes
    nodes={node} 
    //Defines mouse over tooltip
    tooltip=<h1 id="tooltip-in-react-rating-component">Tooltip in React Rating Component</h1>

<p>The rating component supports tooltip to show additional information in rating items by setting the <a href="https://ej2.syncfusion.com/react/documentation/api/rating/#showtooltip"><code>showTooltip</code></a> property. If enabled, the tooltip appears when the user hovers over a rating item.</p>

<div class="tabs" id="code-snippet-1">

<ul class="nav nav-tabs" role="tablist">

<li role="presentation" class=""><a data-target="#dl6n7q0wcfe3woaocdpcs4eeubtvccyp-js" aria-controls="home" role="tab" data-toggle="tab" data-original-lang="js">index.jsx</a></li>
<li role="presentation" class=""><a data-target="#tusza991sr0e577o4xm26tri68d612h3-ts" aria-controls="home" role="tab" data-toggle="tab" data-original-lang="ts">index.tsx</a></li>

</ul>

<div class="tab-content">


<div role="tabpanel" class="tab-pane" id="dl6n7q0wcfe3woaocdpcs4eeubtvccyp-js" data-original-lang="js">
<div class="highlight"><pre><code class="prettyprint language-js" data-lang="js"><span></span><span class="c1">// Import the Rating.</span>
<span class="k">import</span> <span class="p">{</span> <span class="nx">RatingComponent</span> <span class="p">}</span> <span class="kr">from</span> <span class="s1">'@syncfusion/ej2-react-inputs'</span><span class="p">;</span>
<span class="k">import</span> <span class="o">*</span> <span class="kr">as</span> <span class="nx">React</span> <span class="kr">from</span> <span class="s1">'react'</span><span class="p">;</span>
<span class="k">import</span> <span class="o">*</span> <span class="kr">as</span> <span class="nx">ReactDom</span> <span class="kr">from</span> <span class="s1">'react-dom'</span><span class="p">;</span>
<span class="c1">// To render Rating.</span>
<span class="kd">function</span> <span class="nx">App</span><span class="p">()</span> <span class="p">{</span>
    <span class="k">return</span> <span class="p">(</span><span class="o">&lt;</span><span class="nx">div</span> <span class="nx">className</span><span class="o">=</span><span class="s1">'wrap'</span><span class="o">&gt;</span>
            <span class="o">&lt;</span><span class="nx">RatingComponent</span> <span class="nx">id</span><span class="o">=</span><span class="s1">'rating'</span> <span class="nx">showTooltip</span><span class="o">=</span><span class="p">{</span><span class="kc">true</span><span class="p">}</span> <span class="nx">value</span><span class="o">=</span><span class="p">{</span><span class="mf">3</span><span class="p">}</span><span class="o">&gt;&lt;</span><span class="err">/RatingComponent&gt;</span>
        <span class="o">&lt;</span><span class="err">/div&gt;);</span>
<span class="p">}</span>
<span class="k">export</span> <span class="k">default</span> <span class="nx">App</span><span class="p">;</span>
<span class="nx">ReactDom</span><span class="p">.</span><span class="nx">render</span><span class="p">(</span><span class="o">&lt;</span><span class="nx">App</span> <span class="o">/&gt;</span><span class="p">,</span> <span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="s1">'element'</span><span class="p">));</span></code></pre></div>
</div>

<div role="tabpanel" class="tab-pane" id="tusza991sr0e577o4xm26tri68d612h3-ts" data-original-lang="ts">
<div class="highlight"><pre><code class="prettyprint language-ts" data-lang="ts"><span></span><span class="c1">// Import the Rating.</span>
<span class="k">import</span> <span class="p">{</span> <span class="nx">RatingComponent</span> <span class="p">}</span> <span class="kr">from</span> <span class="s1">'@syncfusion/ej2-react-inputs'</span><span class="p">;</span>
<span class="k">import</span> <span class="o">*</span> <span class="kr">as</span> <span class="nx">React</span> <span class="kr">from</span> <span class="s1">'react'</span><span class="p">;</span>
<span class="k">import</span> <span class="o">*</span> <span class="kr">as</span> <span class="nx">ReactDom</span> <span class="kr">from</span> <span class="s1">'react-dom'</span><span class="p">;</span>

<span class="c1">// To render Rating.</span>
<span class="kd">function</span> <span class="nx">App</span><span class="p">()</span> <span class="p">{</span>
  
    <span class="k">return</span> <span class="p">(</span>
        <span class="o">&lt;</span><span class="nx">div</span> <span class="nx">className</span><span class="o">=</span><span class="s1">'wrap'</span><span class="o">&gt;</span>
            <span class="o">&lt;</span><span class="nx">RatingComponent</span> <span class="nx">id</span><span class="o">=</span><span class="s1">'rating'</span> <span class="nx">showTooltip</span><span class="o">=</span><span class="p">{</span><span class="kc">true</span><span class="p">}</span> <span class="nx">value</span><span class="o">=</span><span class="p">{</span><span class="mf">3</span><span class="p">}</span> <span class="o">&gt;&lt;</span><span class="err">/RatingComponent&gt;</span>
        <span class="o">&lt;</span><span class="err">/div&gt;</span>
    <span class="p">);</span>
<span class="p">}</span>
<span class="k">export</span> <span class="k">default</span> <span class="nx">App</span><span class="p">;</span>
<span class="nx">ReactDom</span><span class="p">.</span><span class="nx">render</span><span class="p">(</span><span class="o">&lt;</span><span class="nx">App</span> <span class="o">/&gt;</span><span class="p">,</span><span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="s1">'element'</span><span class="p">));</span></code></pre></div>
</div>

</div>

</div>

<p><button class="preview-sample-button" id="PreviewSampleButton-e3g1gt0u2ngxfewkudkqwdg8zoe3grie" onclick="LoadPreviewSample('https://ej2.syncfusion.com/react/documentation/code-snippet/rating/tooltip/showtooltip-cs1',this.id);">Preview Sample</button><button class="stackblitz-button" id="StackBlitzButton-e3g1gt0u2ngxfewkudkqwdg8zoe3grie" onclick="OpenSampleInStackBlitz('https://ej2.syncfusion.com/react/documentation/code-snippet/rating/tooltip/showtooltip-cs1');"><img class="stackblitz-icon" src="https://cdn.syncfusion.com/documentation/images/StackBlitz-icon.png"><span class="stackblitz-text">Open in Stackblitz</span></button></p>
<div id="PreviewSampleHolder-e3g1gt0u2ngxfewkudkqwdg8zoe3grie"></div>

<h2 id="tooltip-template">Tooltip template</h2>

<p>You can use the <a href="https://ej2.syncfusion.com/react/documentation/api/rating/#tooltiptemplate"><code>tooltipTemplate</code></a> tag directive to specify a custom template for the <code>tooltip</code> of the rating. The current value of the rating will be passed as the <code>value</code> property in the template context when building the content of the tooltip. This allows you to include dynamic information about the rating in the template.</p>

<div class="tabs" id="code-snippet-2">

<ul class="nav nav-tabs" role="tablist">

<li role="presentation" class=""><a data-target="#v32y668atapfui31ufmv4kqjutfnni84-js" aria-controls="home" role="tab" data-toggle="tab" data-original-lang="js">index.jsx</a></li>
<li role="presentation" class=""><a data-target="#8k84637upqqbghwln32l3m2f01jvj1fg-ts" aria-controls="home" role="tab" data-toggle="tab" data-original-lang="ts">index.tsx</a></li>

</ul>

<div class="tab-content">


<div role="tabpanel" class="tab-pane" id="v32y668atapfui31ufmv4kqjutfnni84-js" data-original-lang="js">
<div class="highlight"><pre><code class="prettyprint language-js" data-lang="js"><span></span><span class="c1">// Import the Rating.</span>
<span class="k">import</span> <span class="p">{</span> <span class="nx">RatingComponent</span> <span class="p">}</span> <span class="kr">from</span> <span class="s1">'@syncfusion/ej2-react-inputs'</span><span class="p">;</span>
<span class="k">import</span> <span class="o">*</span> <span class="kr">as</span> <span class="nx">React</span> <span class="kr">from</span> <span class="s1">'react'</span><span class="p">;</span>
<span class="k">import</span> <span class="o">*</span> <span class="kr">as</span> <span class="nx">ReactDom</span> <span class="kr">from</span> <span class="s1">'react-dom'</span><span class="p">;</span>
<span class="c1">// To render Rating.</span>
<span class="kd">function</span> <span class="nx">App</span><span class="p">()</span> <span class="p">{</span>
    <span class="kd">function</span> <span class="nx">tooltipTemplate</span><span class="p">(</span><span class="nx">props</span><span class="p">)</span> <span class="p">{</span>
        <span class="k">if</span> <span class="p">(</span><span class="nx">props</span><span class="p">.</span><span class="nx">value</span> <span class="o">===</span> <span class="mf">1</span><span class="p">)</span> <span class="p">{</span>
            <span class="k">return</span> <span class="p">(</span><span class="o">&lt;</span><span class="nx">b</span><span class="o">&gt;</span><span class="nx">Angry</span><span class="o">&lt;</span><span class="err">/b&gt;);</span>
        <span class="p">}</span>
        <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="nx">props</span><span class="p">.</span><span class="nx">value</span> <span class="o">===</span> <span class="mf">2</span><span class="p">)</span> <span class="p">{</span>
            <span class="k">return</span> <span class="p">(</span><span class="o">&lt;</span><span class="nx">b</span><span class="o">&gt;</span><span class="nx">Sad</span><span class="o">&lt;</span><span class="err">/b&gt;);</span>
        <span class="p">}</span>
        <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="nx">props</span><span class="p">.</span><span class="nx">value</span> <span class="o">===</span> <span class="mf">3</span><span class="p">)</span> <span class="p">{</span>
            <span class="k">return</span> <span class="p">(</span><span class="o">&lt;</span><span class="nx">b</span><span class="o">&gt;</span><span class="nx">Neutral</span><span class="o">&lt;</span><span class="err">/b&gt;);</span>
        <span class="p">}</span>
        <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="nx">props</span><span class="p">.</span><span class="nx">value</span> <span class="o">===</span> <span class="mf">4</span><span class="p">)</span> <span class="p">{</span>
            <span class="k">return</span> <span class="p">(</span><span class="o">&lt;</span><span class="nx">b</span><span class="o">&gt;</span><span class="nx">Good</span><span class="o">&lt;</span><span class="err">/b&gt;);</span>
        <span class="p">}</span>
        <span class="k">else</span> <span class="p">{</span>
            <span class="k">return</span> <span class="p">(</span><span class="o">&lt;</span><span class="nx">b</span><span class="o">&gt;</span><span class="nx">Happy</span><span class="o">&lt;</span><span class="err">/b&gt;);</span>
        <span class="p">}</span>
    <span class="p">}</span>
    <span class="k">return</span> <span class="p">(</span><span class="o">&lt;</span><span class="nx">div</span> <span class="nx">className</span><span class="o">=</span><span class="s1">'wrap'</span><span class="o">&gt;</span>
          <span class="o">&lt;</span><span class="nx">RatingComponent</span> <span class="nx">id</span><span class="o">=</span><span class="s1">'rating'</span> <span class="nx">showTooltip</span><span class="o">=</span><span class="p">{</span><span class="kc">true</span><span class="p">}</span> <span class="nx">value</span><span class="o">=</span><span class="p">{</span><span class="mf">3</span><span class="p">}</span> <span class="nx">tooltipTemplate</span><span class="o">=</span><span class="p">{</span><span class="nx">tooltipTemplate</span><span class="p">}</span><span class="o">&gt;&lt;</span><span class="err">/RatingComponent&gt;</span>
      <span class="o">&lt;</span><span class="err">/div&gt;);</span>
<span class="p">}</span>
<span class="k">export</span> <span class="k">default</span> <span class="nx">App</span><span class="p">;</span>
<span class="nx">ReactDom</span><span class="p">.</span><span class="nx">render</span><span class="p">(</span><span class="o">&lt;</span><span class="nx">App</span> <span class="o">/&gt;</span><span class="p">,</span> <span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="s1">'element'</span><span class="p">));</span></code></pre></div>
</div>

<div role="tabpanel" class="tab-pane" id="8k84637upqqbghwln32l3m2f01jvj1fg-ts" data-original-lang="ts">
<div class="highlight"><pre><code class="prettyprint language-ts" data-lang="ts"><span></span><span class="c1">// Import the Rating.</span>
<span class="k">import</span> <span class="p">{</span> <span class="nx">RatingComponent</span> <span class="p">}</span> <span class="kr">from</span> <span class="s1">'@syncfusion/ej2-react-inputs'</span><span class="p">;</span>
<span class="k">import</span> <span class="o">*</span> <span class="kr">as</span> <span class="nx">React</span> <span class="kr">from</span> <span class="s1">'react'</span><span class="p">;</span>
<span class="k">import</span> <span class="o">*</span> <span class="kr">as</span> <span class="nx">ReactDom</span> <span class="kr">from</span> <span class="s1">'react-dom'</span><span class="p">;</span>

<span class="c1">// To render Rating.</span>
<span class="kd">function</span> <span class="nx">App</span><span class="p">()</span> <span class="p">{</span>

    <span class="kd">function</span> <span class="nx">tooltipTemplate</span><span class="p">(</span><span class="nx">props</span>: <span class="kt">any</span><span class="p">)</span> <span class="p">{</span>
        <span class="k">if</span><span class="p">(</span><span class="nx">props</span><span class="p">.</span><span class="nx">value</span> <span class="o">===</span> <span class="mf">1</span><span class="p">){</span>
            <span class="k">return</span> <span class="p">(</span><span class="o">&lt;</span><span class="nx">b</span><span class="o">&gt;</span><span class="nx">Angry</span><span class="o">&lt;</span><span class="err">/b&gt;);}</span>
        <span class="k">else</span> <span class="k">if</span><span class="p">(</span><span class="nx">props</span><span class="p">.</span><span class="nx">value</span> <span class="o">===</span> <span class="mf">2</span><span class="p">){</span>
            <span class="k">return</span> <span class="p">(</span><span class="o">&lt;</span><span class="nx">b</span><span class="o">&gt;</span><span class="nx">Sad</span><span class="o">&lt;</span><span class="err">/b&gt;);}</span>
        <span class="k">else</span> <span class="k">if</span><span class="p">(</span><span class="nx">props</span><span class="p">.</span><span class="nx">value</span> <span class="o">===</span> <span class="mf">3</span><span class="p">){</span>
            <span class="k">return</span> <span class="p">(</span><span class="o">&lt;</span><span class="nx">b</span><span class="o">&gt;</span><span class="nx">Neutral</span><span class="o">&lt;</span><span class="err">/b&gt;);}</span>
        <span class="k">else</span> <span class="k">if</span><span class="p">(</span><span class="nx">props</span><span class="p">.</span><span class="nx">value</span> <span class="o">===</span> <span class="mf">4</span><span class="p">){</span>
            <span class="k">return</span> <span class="p">(</span><span class="o">&lt;</span><span class="nx">b</span><span class="o">&gt;</span><span class="nx">Good</span><span class="o">&lt;</span><span class="err">/b&gt;);}</span>
        <span class="k">else</span> <span class="p">{</span>
            <span class="k">return</span> <span class="p">(</span><span class="o">&lt;</span><span class="nx">b</span><span class="o">&gt;</span><span class="nx">Happy</span><span class="o">&lt;</span><span class="err">/b&gt;);}</span>
    <span class="p">}</span>
  
    <span class="k">return</span> <span class="p">(</span>
        <span class="o">&lt;</span><span class="nx">div</span> <span class="nx">className</span><span class="o">=</span><span class="s1">'wrap'</span><span class="o">&gt;</span>
            <span class="o">&lt;</span><span class="nx">RatingComponent</span> <span class="nx">id</span><span class="o">=</span><span class="s1">'rating'</span> <span class="nx">showTooltip</span><span class="o">=</span><span class="p">{</span><span class="kc">true</span><span class="p">}</span> <span class="nx">value</span><span class="o">=</span><span class="p">{</span><span class="mf">3</span><span class="p">}</span> <span class="nx">tooltipTemplate</span><span class="o">=</span><span class="p">{</span><span class="nx">tooltipTemplate</span><span class="p">}</span> <span class="o">&gt;&lt;</span><span class="err">/RatingComponent&gt;</span>
        <span class="o">&lt;</span><span class="err">/div&gt;</span>
    <span class="p">);</span>
<span class="p">}</span>
<span class="k">export</span> <span class="k">default</span> <span class="nx">App</span><span class="p">;</span>
<span class="nx">ReactDom</span><span class="p">.</span><span class="nx">render</span><span class="p">(</span><span class="o">&lt;</span><span class="nx">App</span> <span class="o">/&gt;</span><span class="p">,</span><span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="s1">'element'</span><span class="p">));</span></code></pre></div>
</div>

</div>

</div>

<p><button class="preview-sample-button" id="PreviewSampleButton-rks1aag7xch7axcvy1s11f80vy7hlu0c" onclick="LoadPreviewSample('https://ej2.syncfusion.com/react/documentation/code-snippet/rating/tooltip/tooltip-template-cs1',this.id);">Preview Sample</button><button class="stackblitz-button" id="StackBlitzButton-rks1aag7xch7axcvy1s11f80vy7hlu0c" onclick="OpenSampleInStackBlitz('https://ej2.syncfusion.com/react/documentation/code-snippet/rating/tooltip/tooltip-template-cs1');"><img class="stackblitz-icon" src="https://cdn.syncfusion.com/documentation/images/StackBlitz-icon.png"><span class="stackblitz-text">Open in Stackblitz</span></button></p>
<div id="PreviewSampleHolder-rks1aag7xch7axcvy1s11f80vy7hlu0c"></div>

<h2 id="tooltip-customization">Tooltip customization</h2>

<p>You can customize the appearance of the tooltips using the <code>cssClass</code> property of the rating component and by defining the custom styles for tooltip elements like the below example.</p>

<blockquote>
  <p>You can find more information about customizing the appearance of the tooltip in the <a href="https://ej2.syncfusion.com/react/documentation/tooltip/style/">Tooltip Customization</a> documentation.</p>
</blockquote>

<div class="tabs" id="code-snippet-3">

<ul class="nav nav-tabs" role="tablist">

<li role="presentation" class=""><a data-target="#2bwj3rbta2k6j07fyg97q3kp9uu4l1f3-js" aria-controls="home" role="tab" data-toggle="tab" data-original-lang="js">index.jsx</a></li>
<li role="presentation" class=""><a data-target="#pyrpw0fzkuci9lbs9gdb2wtvnm3m6hio-ts" aria-controls="home" role="tab" data-toggle="tab" data-original-lang="ts">index.tsx</a></li>
<li role="presentation" class=""><a data-target="#8maqbq35304e8d1c9gihyflcyj827o90-ts" aria-controls="home" role="tab" data-toggle="tab" data-original-lang="ts">styles.css</a></li>

</ul>

<div class="tab-content">


<div role="tabpanel" class="tab-pane" id="2bwj3rbta2k6j07fyg97q3kp9uu4l1f3-js" data-original-lang="js">
<div class="highlight"><pre><code class="prettyprint language-js" data-lang="js"><span></span><span class="c1">// Import the Rating.</span>
<span class="k">import</span> <span class="p">{</span> <span class="nx">RatingComponent</span> <span class="p">}</span> <span class="kr">from</span> <span class="s1">'@syncfusion/ej2-react-inputs'</span><span class="p">;</span>
<span class="k">import</span> <span class="o">*</span> <span class="kr">as</span> <span class="nx">React</span> <span class="kr">from</span> <span class="s1">'react'</span><span class="p">;</span>
<span class="k">import</span> <span class="o">*</span> <span class="kr">as</span> <span class="nx">ReactDom</span> <span class="kr">from</span> <span class="s1">'react-dom'</span><span class="p">;</span>
<span class="c1">// To render Rating.</span>
<span class="kd">function</span> <span class="nx">App</span><span class="p">()</span> <span class="p">{</span>
    <span class="k">return</span> <span class="p">(</span><span class="o">&lt;</span><span class="nx">div</span> <span class="nx">className</span><span class="o">=</span><span class="s1">'wrap'</span><span class="o">&gt;</span>
          <span class="o">&lt;</span><span class="nx">RatingComponent</span> <span class="nx">id</span><span class="o">=</span><span class="s1">'rating'</span> <span class="nx">showTooltip</span><span class="o">=</span><span class="p">{</span><span class="kc">true</span><span class="p">}</span> <span class="nx">value</span><span class="o">=</span><span class="p">{</span><span class="mf">3</span><span class="p">}</span> <span class="nx">cssClass</span><span class="o">=</span><span class="s1">'customtooltip'</span><span class="o">&gt;&lt;</span><span class="err">/RatingComponent&gt;</span>
      <span class="o">&lt;</span><span class="err">/div&gt;);</span>
<span class="p">}</span>
<span class="k">export</span> <span class="k">default</span> <span class="nx">App</span><span class="p">;</span>
<span class="nx">ReactDom</span><span class="p">.</span><span class="nx">render</span><span class="p">(</span><span class="o">&lt;</span><span class="nx">App</span> <span class="o">/&gt;</span><span class="p">,</span> <span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="s1">'element'</span><span class="p">));</span></code></pre></div>
</div>

<div role="tabpanel" class="tab-pane" id="pyrpw0fzkuci9lbs9gdb2wtvnm3m6hio-ts" data-original-lang="ts">
<div class="highlight"><pre><code class="prettyprint language-ts" data-lang="ts"><span></span><span class="c1">// Import the Rating.</span>
<span class="k">import</span> <span class="p">{</span> <span class="nx">RatingComponent</span> <span class="p">}</span> <span class="kr">from</span> <span class="s1">'@syncfusion/ej2-react-inputs'</span><span class="p">;</span>
<span class="k">import</span> <span class="o">*</span> <span class="kr">as</span> <span class="nx">React</span> <span class="kr">from</span> <span class="s1">'react'</span><span class="p">;</span>
<span class="k">import</span> <span class="o">*</span> <span class="kr">as</span> <span class="nx">ReactDom</span> <span class="kr">from</span> <span class="s1">'react-dom'</span><span class="p">;</span>

<span class="c1">// To render Rating.</span>
<span class="kd">function</span> <span class="nx">App</span><span class="p">()</span> <span class="p">{</span>
  
    <span class="k">return</span> <span class="p">(</span>
        <span class="o">&lt;</span><span class="nx">div</span> <span class="nx">className</span><span class="o">=</span><span class="s1">'wrap'</span><span class="o">&gt;</span>
            <span class="o">&lt;</span><span class="nx">RatingComponent</span> <span class="nx">id</span><span class="o">=</span><span class="s1">'rating'</span> <span class="nx">showTooltip</span><span class="o">=</span><span class="p">{</span><span class="kc">true</span><span class="p">}</span> <span class="nx">value</span><span class="o">=</span><span class="p">{</span><span class="mf">3</span><span class="p">}</span> <span class="nx">cssClass</span><span class="o">=</span><span class="s1">'customtooltip'</span> <span class="o">&gt;&lt;</span><span class="err">/RatingComponent&gt;</span>
        <span class="o">&lt;</span><span class="err">/div&gt;</span>
    <span class="p">);</span>
<span class="p">}</span>
<span class="k">export</span> <span class="k">default</span> <span class="nx">App</span><span class="p">;</span>
<span class="nx">ReactDom</span><span class="p">.</span><span class="nx">render</span><span class="p">(</span><span class="o">&lt;</span><span class="nx">App</span> <span class="o">/&gt;</span><span class="p">,</span><span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="s1">'element'</span><span class="p">));</span></code></pre></div>
</div>

<div role="tabpanel" class="tab-pane" id="8maqbq35304e8d1c9gihyflcyj827o90-ts" data-original-lang="ts">
<div class="highlight"><pre><code class="prettyprint language-ts" data-lang="ts"><span></span><span class="cm">/* Represents the styles for loader */</span>
<span class="err">#</span><span class="nx">loader</span> <span class="p">{</span>
    <span class="nx">color</span><span class="o">:</span> <span class="err">#</span><span class="mo">00</span><span class="mf">8</span><span class="nx">cff</span><span class="p">;</span>
    <span class="nx">font</span><span class="o">-</span><span class="nx">family</span><span class="o">:</span> <span class="s1">'Helvetica Neue'</span><span class="p">,</span> <span class="s1">'calibiri'</span><span class="p">;</span>
    <span class="nx">font</span><span class="o">-</span><span class="nx">size</span>: <span class="kt">14px</span><span class="p">;</span>
    <span class="nx">height</span>: <span class="kt">40px</span><span class="p">;</span>
    <span class="nx">left</span>: <span class="kt">45</span><span class="o">%</span><span class="p">;</span>
    <span class="nx">position</span>: <span class="kt">absolute</span><span class="p">;</span>
    <span class="nx">top</span>: <span class="kt">45</span><span class="o">%</span><span class="p">;</span>
    <span class="nx">width</span>: <span class="kt">30</span><span class="o">%</span><span class="p">;</span>
<span class="p">}</span>

<span class="p">.</span><span class="nx">wrap</span> <span class="p">{</span>
    <span class="nx">margin</span>: <span class="kt">50px</span> <span class="nx">auto</span><span class="p">;</span>
    <span class="nx">text</span><span class="o">-</span><span class="nx">align</span>: <span class="kt">center</span><span class="p">;</span>
<span class="p">}</span>

<span class="cm">/* To change the radius of the tooltip corners. */</span>
<span class="p">.</span><span class="nx">customtooltip</span><span class="p">.</span><span class="nx">e</span><span class="o">-</span><span class="nx">tooltip</span><span class="o">-</span><span class="nx">wrap</span> <span class="p">{</span>
  <span class="nx">border</span><span class="o">-</span><span class="nx">radius</span>: <span class="kt">3px</span><span class="p">;</span>
<span class="p">}</span>

<span class="cm">/* To change the size of the tooltip content. */</span>
<span class="p">.</span><span class="nx">customtooltip</span><span class="p">.</span><span class="nx">e</span><span class="o">-</span><span class="nx">tooltip</span><span class="o">-</span><span class="nx">wrap</span> <span class="p">.</span><span class="nx">e</span><span class="o">-</span><span class="nx">tip</span><span class="o">-</span><span class="nx">content</span> <span class="p">{</span>
  <span class="nx">font</span><span class="o">-</span><span class="nx">size</span>:<span class="kt">14px</span><span class="p">;</span>
<span class="p">}</span>

<span class="cm">/* To change the border color and width for tooltip. */</span>
<span class="p">.</span><span class="nx">customtooltip</span><span class="p">.</span><span class="nx">e</span><span class="o">-</span><span class="nx">tooltip</span><span class="o">-</span><span class="nx">wrap</span><span class="p">.</span><span class="nx">e</span><span class="o">-</span><span class="nx">popup</span> <span class="p">{</span>
  <span class="nx">border</span>: <span class="kt">2px</span> <span class="nx">solid</span> <span class="err">#</span><span class="mo">000000</span><span class="p">;</span>
<span class="p">}</span>

<span class="cm">/* To change the color for arrow of the tooltip. */</span>
<span class="p">.</span><span class="nx">customtooltip</span><span class="p">.</span><span class="nx">e</span><span class="o">-</span><span class="nx">tooltip</span><span class="o">-</span><span class="nx">wrap</span> <span class="p">.</span><span class="nx">e</span><span class="o">-</span><span class="nx">arrow</span><span class="o">-</span><span class="nx">tip</span><span class="o">-</span><span class="nx">inner</span><span class="p">.</span><span class="nx">e</span><span class="o">-</span><span class="nx">tip</span><span class="o">-</span><span class="nx">bottom</span> <span class="p">{</span>
  <span class="nx">border</span>: <span class="kt">12px</span> <span class="err">#</span><span class="mf">9693</span>
<span class="p">}</span>

<span class="cm">/* To change the top border color for arrow of the tooltip. */</span>
<span class="p">.</span><span class="nx">customtooltip</span><span class="p">.</span><span class="nx">e</span><span class="o">-</span><span class="nx">tooltip</span><span class="o">-</span><span class="nx">wrap</span> <span class="p">.</span><span class="nx">e</span><span class="o">-</span><span class="nx">arrow</span><span class="o">-</span><span class="nx">tip</span><span class="o">-</span><span class="nx">outer</span><span class="p">.</span><span class="nx">e</span><span class="o">-</span><span class="nx">tip</span><span class="o">-</span><span class="nx">bottom</span> <span class="p">{</span>
  <span class="nx">border</span><span class="o">-</span><span class="nx">top</span>: <span class="kt">9.5px</span> <span class="nx">solid</span> <span class="err">#</span><span class="mo">000000</span><span class="p">;</span>
<span class="p">}</span></code></pre></div>
</div>

</div>

</div>

<p><button class="preview-sample-button" id="PreviewSampleButton-q43a5q9g041jvllkj3afg6a1zjvivnip" onclick="LoadPreviewSample('https://ej2.syncfusion.com/react/documentation/code-snippet/rating/tooltip/custom-tooltip-cs1',this.id);">Preview Sample</button><button class="stackblitz-button" id="StackBlitzButton-q43a5q9g041jvllkj3afg6a1zjvivnip" onclick="OpenSampleInStackBlitz('https://ej2.syncfusion.com/react/documentation/code-snippet/rating/tooltip/custom-tooltip-cs1');"><img class="stackblitz-icon" src="https://cdn.syncfusion.com/documentation/images/StackBlitz-icon.png"><span class="stackblitz-text">Open in Stackblitz</span></button></p>
<div id="PreviewSampleHolder-q43a5q9g041jvllkj3afg6a1zjvivnip"></div>
/>);
}
const root = ReactDOM.createRoot(document.getElementById('diagram'));
root.render(<App />);

Tooltip for a specific node/connector

The tooltip can be customized for each node and connector. Remove the InheritTooltip option from the constraints of that node/connector. The following code example illustrates how to customize the tooltip for individual elements.

import * as React from "react";
import * as ReactDOM from "react-dom";
import { DiagramComponent, DiagramConstraints, NodeConstraints,ConnectorConstraints } from "@syncfusion/ej2-react-diagrams";
// A node is created and stored in nodes array.
let node = [{
        id: "node1",
        width: 100,
        height: 100,
        annotations: [{
                id: 'label',
                content: 'Rectangle',
                offset: {
                    x: 0.5,
                    y: 0.5
                },
                style: {
                    color: 'white'
                },
            }],
        offsetX: 200,
        offsetY: 200,
        style: {
            strokeColor: '#6BA5D7',
            fill: '#6BA5D7'
        },
        constraints: NodeConstraints.Default | NodeConstraints.Tooltip,
        //Defines mouse over tooltip for a node
        tooltip: {
            //Sets the content of the Tooltip
            content: 'Node1',
            //Sets the position of the Tooltip
            position: 'BottomRight',
            //Sets the tooltip position relative to the node
            relativeMode: 'Object'
        },
    }];
let connector = [{
    id: 'connector1',
    sourcePoint: { x: 300, y: 100 },
    targetPoint: { x: 400, y: 250 },
    tooltip: { content: 'connector' },
    constraints: ConnectorConstraints.Default | ConnectorConstraints.Tooltip, 
}]
//Initializes the Diagram component
function App() {
    return (<DiagramComponent id="container" width={'650px'} height={'350px'} constraints={DiagramConstraints.Default | DiagramConstraints.Tooltip} 
    //Defines nodes
    nodes={node} connectors={connector}
    />);
}
const root = ReactDOM.createRoot(document.getElementById('diagram'));
root.render(<App />);
import * as React from "react";
import * as ReactDOM from "react-dom";
import { DiagramComponent, DiagramConstraints, NodeConstraints,ConnectorConstraints,NodeModel, } from "@syncfusion/ej2-react-diagrams";
// A node is created and stored in nodes array.
let node:NodeModel[] = [{
        id: "node1",
        width: 100,
        height: 100,
        annotations: [{
                id: 'label',
                content: 'Rectangle',
                offset: {
                    x: 0.5,
                    y: 0.5
                },
                style: {
                    color: 'white'
                },
            }],
        offsetX: 200,
        offsetY: 200,
        style: {
            strokeColor: '#6BA5D7',
            fill: '#6BA5D7'
        },
        constraints: NodeConstraints.Default | NodeConstraints.Tooltip,
        //Defines mouse over tooltip for a node
        tooltip: {
            //Sets the content of the Tooltip
            content: 'Node1',
            //Sets the position of the Tooltip
            position: 'BottomRight',
            //Sets the tooltip position relative to the node
            relativeMode: 'Object'
        },
    }];
let connector = [{
    id: 'connector1',
    sourcePoint: { x: 300, y: 100 },
    targetPoint: { x: 400, y: 250 },
    tooltip: { content: 'connector' },
    constraints: ConnectorConstraints.Default | ConnectorConstraints.Tooltip, 
}]
//Initializes the Diagram component
function App() {
    return (<DiagramComponent id="container" width={'650px'} height={'350px'} constraints={DiagramConstraints.Default | DiagramConstraints.Tooltip} 
    //Defines nodes
    nodes={node} connectors={connector}
    />);
}
const root = ReactDOM.createRoot(document.getElementById('diagram'));
root.render(<App />);

Inherit diagram tooltip

The diagram supports inheriting the diagram tooltip when the mouse hovers over any node or connector. To show a tooltip on mouse over, set the diagram’s tooltip property with the tooltip content and position. Ensure that the nodes and connectors have their constraints set to InheritTooltip, as shown in the following example.

import * as React from "react";
import * as ReactDOM from "react-dom";
import { DiagramComponent, DiagramConstraints, NodeConstraints,ConnectorConstraints } from "@syncfusion/ej2-react-diagrams";
// A node is created and stored in nodes array.
let node = [{
        id: "node1",
        width: 100,
        height: 100,
        annotations: [{
                id: 'label',
                content: 'Rectangle',
                offset: {
                    x: 0.5,
                    y: 0.5
                },
                style: {
                    color: 'white'
                },
            }],
        offsetX: 200,
        offsetY: 200,
        style: {
            strokeColor: '#6BA5D7',
            fill: '#6BA5D7'
        },
        constraints: NodeConstraints.Default | NodeConstraints.InheritTooltip,
        //Defines mouse over tooltip for a node
        tooltip: {
            //Sets the content of the Tooltip
            content: 'Node1',
        },
    }];
let connector = [{
    id: 'connector1',
    sourcePoint: { x: 300, y: 100 },
    targetPoint: { x: 400, y: 250 },
    tooltip: { content: 'connector' },
    constraints: ConnectorConstraints.Default | ConnectorConstraints.InheritTooltip, 
}]
//Initializes the Diagram component
function App() {
    return (<DiagramComponent id="container" width={'650px'} height={'350px'} constraints={DiagramConstraints.Default | DiagramConstraints.Tooltip} 
    //Defines nodes
    nodes={node} connectors={connector}
     //Defines mouse over tooltip for a node
     tooltip=<h1 id="tooltip-in-react-rating-component">Tooltip in React Rating Component</h1>

<p>The rating component supports tooltip to show additional information in rating items by setting the <a href="https://ej2.syncfusion.com/react/documentation/api/rating/#showtooltip"><code>showTooltip</code></a> property. If enabled, the tooltip appears when the user hovers over a rating item.</p>

<div class="tabs" id="code-snippet-1">

<ul class="nav nav-tabs" role="tablist">

<li role="presentation" class=""><a data-target="#dl6n7q0wcfe3woaocdpcs4eeubtvccyp-js" aria-controls="home" role="tab" data-toggle="tab" data-original-lang="js">index.jsx</a></li>
<li role="presentation" class=""><a data-target="#tusza991sr0e577o4xm26tri68d612h3-ts" aria-controls="home" role="tab" data-toggle="tab" data-original-lang="ts">index.tsx</a></li>

</ul>

<div class="tab-content">


<div role="tabpanel" class="tab-pane" id="dl6n7q0wcfe3woaocdpcs4eeubtvccyp-js" data-original-lang="js">
<div class="highlight"><pre><code class="prettyprint language-js" data-lang="js"><span></span><span class="c1">// Import the Rating.</span>
<span class="k">import</span> <span class="p">{</span> <span class="nx">RatingComponent</span> <span class="p">}</span> <span class="kr">from</span> <span class="s1">'@syncfusion/ej2-react-inputs'</span><span class="p">;</span>
<span class="k">import</span> <span class="o">*</span> <span class="kr">as</span> <span class="nx">React</span> <span class="kr">from</span> <span class="s1">'react'</span><span class="p">;</span>
<span class="k">import</span> <span class="o">*</span> <span class="kr">as</span> <span class="nx">ReactDom</span> <span class="kr">from</span> <span class="s1">'react-dom'</span><span class="p">;</span>
<span class="c1">// To render Rating.</span>
<span class="kd">function</span> <span class="nx">App</span><span class="p">()</span> <span class="p">{</span>
    <span class="k">return</span> <span class="p">(</span><span class="o">&lt;</span><span class="nx">div</span> <span class="nx">className</span><span class="o">=</span><span class="s1">'wrap'</span><span class="o">&gt;</span>
            <span class="o">&lt;</span><span class="nx">RatingComponent</span> <span class="nx">id</span><span class="o">=</span><span class="s1">'rating'</span> <span class="nx">showTooltip</span><span class="o">=</span><span class="p">{</span><span class="kc">true</span><span class="p">}</span> <span class="nx">value</span><span class="o">=</span><span class="p">{</span><span class="mf">3</span><span class="p">}</span><span class="o">&gt;&lt;</span><span class="err">/RatingComponent&gt;</span>
        <span class="o">&lt;</span><span class="err">/div&gt;);</span>
<span class="p">}</span>
<span class="k">export</span> <span class="k">default</span> <span class="nx">App</span><span class="p">;</span>
<span class="nx">ReactDom</span><span class="p">.</span><span class="nx">render</span><span class="p">(</span><span class="o">&lt;</span><span class="nx">App</span> <span class="o">/&gt;</span><span class="p">,</span> <span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="s1">'element'</span><span class="p">));</span></code></pre></div>
</div>

<div role="tabpanel" class="tab-pane" id="tusza991sr0e577o4xm26tri68d612h3-ts" data-original-lang="ts">
<div class="highlight"><pre><code class="prettyprint language-ts" data-lang="ts"><span></span><span class="c1">// Import the Rating.</span>
<span class="k">import</span> <span class="p">{</span> <span class="nx">RatingComponent</span> <span class="p">}</span> <span class="kr">from</span> <span class="s1">'@syncfusion/ej2-react-inputs'</span><span class="p">;</span>
<span class="k">import</span> <span class="o">*</span> <span class="kr">as</span> <span class="nx">React</span> <span class="kr">from</span> <span class="s1">'react'</span><span class="p">;</span>
<span class="k">import</span> <span class="o">*</span> <span class="kr">as</span> <span class="nx">ReactDom</span> <span class="kr">from</span> <span class="s1">'react-dom'</span><span class="p">;</span>

<span class="c1">// To render Rating.</span>
<span class="kd">function</span> <span class="nx">App</span><span class="p">()</span> <span class="p">{</span>
  
    <span class="k">return</span> <span class="p">(</span>
        <span class="o">&lt;</span><span class="nx">div</span> <span class="nx">className</span><span class="o">=</span><span class="s1">'wrap'</span><span class="o">&gt;</span>
            <span class="o">&lt;</span><span class="nx">RatingComponent</span> <span class="nx">id</span><span class="o">=</span><span class="s1">'rating'</span> <span class="nx">showTooltip</span><span class="o">=</span><span class="p">{</span><span class="kc">true</span><span class="p">}</span> <span class="nx">value</span><span class="o">=</span><span class="p">{</span><span class="mf">3</span><span class="p">}</span> <span class="o">&gt;&lt;</span><span class="err">/RatingComponent&gt;</span>
        <span class="o">&lt;</span><span class="err">/div&gt;</span>
    <span class="p">);</span>
<span class="p">}</span>
<span class="k">export</span> <span class="k">default</span> <span class="nx">App</span><span class="p">;</span>
<span class="nx">ReactDom</span><span class="p">.</span><span class="nx">render</span><span class="p">(</span><span class="o">&lt;</span><span class="nx">App</span> <span class="o">/&gt;</span><span class="p">,</span><span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="s1">'element'</span><span class="p">));</span></code></pre></div>
</div>

</div>

</div>

<p><button class="preview-sample-button" id="PreviewSampleButton-e3g1gt0u2ngxfewkudkqwdg8zoe3grie" onclick="LoadPreviewSample('https://ej2.syncfusion.com/react/documentation/code-snippet/rating/tooltip/showtooltip-cs1',this.id);">Preview Sample</button><button class="stackblitz-button" id="StackBlitzButton-e3g1gt0u2ngxfewkudkqwdg8zoe3grie" onclick="OpenSampleInStackBlitz('https://ej2.syncfusion.com/react/documentation/code-snippet/rating/tooltip/showtooltip-cs1');"><img class="stackblitz-icon" src="https://cdn.syncfusion.com/documentation/images/StackBlitz-icon.png"><span class="stackblitz-text">Open in Stackblitz</span></button></p>
<div id="PreviewSampleHolder-e3g1gt0u2ngxfewkudkqwdg8zoe3grie"></div>

<h2 id="tooltip-template">Tooltip template</h2>

<p>You can use the <a href="https://ej2.syncfusion.com/react/documentation/api/rating/#tooltiptemplate"><code>tooltipTemplate</code></a> tag directive to specify a custom template for the <code>tooltip</code> of the rating. The current value of the rating will be passed as the <code>value</code> property in the template context when building the content of the tooltip. This allows you to include dynamic information about the rating in the template.</p>

<div class="tabs" id="code-snippet-2">

<ul class="nav nav-tabs" role="tablist">

<li role="presentation" class=""><a data-target="#v32y668atapfui31ufmv4kqjutfnni84-js" aria-controls="home" role="tab" data-toggle="tab" data-original-lang="js">index.jsx</a></li>
<li role="presentation" class=""><a data-target="#8k84637upqqbghwln32l3m2f01jvj1fg-ts" aria-controls="home" role="tab" data-toggle="tab" data-original-lang="ts">index.tsx</a></li>

</ul>

<div class="tab-content">


<div role="tabpanel" class="tab-pane" id="v32y668atapfui31ufmv4kqjutfnni84-js" data-original-lang="js">
<div class="highlight"><pre><code class="prettyprint language-js" data-lang="js"><span></span><span class="c1">// Import the Rating.</span>
<span class="k">import</span> <span class="p">{</span> <span class="nx">RatingComponent</span> <span class="p">}</span> <span class="kr">from</span> <span class="s1">'@syncfusion/ej2-react-inputs'</span><span class="p">;</span>
<span class="k">import</span> <span class="o">*</span> <span class="kr">as</span> <span class="nx">React</span> <span class="kr">from</span> <span class="s1">'react'</span><span class="p">;</span>
<span class="k">import</span> <span class="o">*</span> <span class="kr">as</span> <span class="nx">ReactDom</span> <span class="kr">from</span> <span class="s1">'react-dom'</span><span class="p">;</span>
<span class="c1">// To render Rating.</span>
<span class="kd">function</span> <span class="nx">App</span><span class="p">()</span> <span class="p">{</span>
    <span class="kd">function</span> <span class="nx">tooltipTemplate</span><span class="p">(</span><span class="nx">props</span><span class="p">)</span> <span class="p">{</span>
        <span class="k">if</span> <span class="p">(</span><span class="nx">props</span><span class="p">.</span><span class="nx">value</span> <span class="o">===</span> <span class="mf">1</span><span class="p">)</span> <span class="p">{</span>
            <span class="k">return</span> <span class="p">(</span><span class="o">&lt;</span><span class="nx">b</span><span class="o">&gt;</span><span class="nx">Angry</span><span class="o">&lt;</span><span class="err">/b&gt;);</span>
        <span class="p">}</span>
        <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="nx">props</span><span class="p">.</span><span class="nx">value</span> <span class="o">===</span> <span class="mf">2</span><span class="p">)</span> <span class="p">{</span>
            <span class="k">return</span> <span class="p">(</span><span class="o">&lt;</span><span class="nx">b</span><span class="o">&gt;</span><span class="nx">Sad</span><span class="o">&lt;</span><span class="err">/b&gt;);</span>
        <span class="p">}</span>
        <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="nx">props</span><span class="p">.</span><span class="nx">value</span> <span class="o">===</span> <span class="mf">3</span><span class="p">)</span> <span class="p">{</span>
            <span class="k">return</span> <span class="p">(</span><span class="o">&lt;</span><span class="nx">b</span><span class="o">&gt;</span><span class="nx">Neutral</span><span class="o">&lt;</span><span class="err">/b&gt;);</span>
        <span class="p">}</span>
        <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="nx">props</span><span class="p">.</span><span class="nx">value</span> <span class="o">===</span> <span class="mf">4</span><span class="p">)</span> <span class="p">{</span>
            <span class="k">return</span> <span class="p">(</span><span class="o">&lt;</span><span class="nx">b</span><span class="o">&gt;</span><span class="nx">Good</span><span class="o">&lt;</span><span class="err">/b&gt;);</span>
        <span class="p">}</span>
        <span class="k">else</span> <span class="p">{</span>
            <span class="k">return</span> <span class="p">(</span><span class="o">&lt;</span><span class="nx">b</span><span class="o">&gt;</span><span class="nx">Happy</span><span class="o">&lt;</span><span class="err">/b&gt;);</span>
        <span class="p">}</span>
    <span class="p">}</span>
    <span class="k">return</span> <span class="p">(</span><span class="o">&lt;</span><span class="nx">div</span> <span class="nx">className</span><span class="o">=</span><span class="s1">'wrap'</span><span class="o">&gt;</span>
          <span class="o">&lt;</span><span class="nx">RatingComponent</span> <span class="nx">id</span><span class="o">=</span><span class="s1">'rating'</span> <span class="nx">showTooltip</span><span class="o">=</span><span class="p">{</span><span class="kc">true</span><span class="p">}</span> <span class="nx">value</span><span class="o">=</span><span class="p">{</span><span class="mf">3</span><span class="p">}</span> <span class="nx">tooltipTemplate</span><span class="o">=</span><span class="p">{</span><span class="nx">tooltipTemplate</span><span class="p">}</span><span class="o">&gt;&lt;</span><span class="err">/RatingComponent&gt;</span>
      <span class="o">&lt;</span><span class="err">/div&gt;);</span>
<span class="p">}</span>
<span class="k">export</span> <span class="k">default</span> <span class="nx">App</span><span class="p">;</span>
<span class="nx">ReactDom</span><span class="p">.</span><span class="nx">render</span><span class="p">(</span><span class="o">&lt;</span><span class="nx">App</span> <span class="o">/&gt;</span><span class="p">,</span> <span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="s1">'element'</span><span class="p">));</span></code></pre></div>
</div>

<div role="tabpanel" class="tab-pane" id="8k84637upqqbghwln32l3m2f01jvj1fg-ts" data-original-lang="ts">
<div class="highlight"><pre><code class="prettyprint language-ts" data-lang="ts"><span></span><span class="c1">// Import the Rating.</span>
<span class="k">import</span> <span class="p">{</span> <span class="nx">RatingComponent</span> <span class="p">}</span> <span class="kr">from</span> <span class="s1">'@syncfusion/ej2-react-inputs'</span><span class="p">;</span>
<span class="k">import</span> <span class="o">*</span> <span class="kr">as</span> <span class="nx">React</span> <span class="kr">from</span> <span class="s1">'react'</span><span class="p">;</span>
<span class="k">import</span> <span class="o">*</span> <span class="kr">as</span> <span class="nx">ReactDom</span> <span class="kr">from</span> <span class="s1">'react-dom'</span><span class="p">;</span>

<span class="c1">// To render Rating.</span>
<span class="kd">function</span> <span class="nx">App</span><span class="p">()</span> <span class="p">{</span>

    <span class="kd">function</span> <span class="nx">tooltipTemplate</span><span class="p">(</span><span class="nx">props</span>: <span class="kt">any</span><span class="p">)</span> <span class="p">{</span>
        <span class="k">if</span><span class="p">(</span><span class="nx">props</span><span class="p">.</span><span class="nx">value</span> <span class="o">===</span> <span class="mf">1</span><span class="p">){</span>
            <span class="k">return</span> <span class="p">(</span><span class="o">&lt;</span><span class="nx">b</span><span class="o">&gt;</span><span class="nx">Angry</span><span class="o">&lt;</span><span class="err">/b&gt;);}</span>
        <span class="k">else</span> <span class="k">if</span><span class="p">(</span><span class="nx">props</span><span class="p">.</span><span class="nx">value</span> <span class="o">===</span> <span class="mf">2</span><span class="p">){</span>
            <span class="k">return</span> <span class="p">(</span><span class="o">&lt;</span><span class="nx">b</span><span class="o">&gt;</span><span class="nx">Sad</span><span class="o">&lt;</span><span class="err">/b&gt;);}</span>
        <span class="k">else</span> <span class="k">if</span><span class="p">(</span><span class="nx">props</span><span class="p">.</span><span class="nx">value</span> <span class="o">===</span> <span class="mf">3</span><span class="p">){</span>
            <span class="k">return</span> <span class="p">(</span><span class="o">&lt;</span><span class="nx">b</span><span class="o">&gt;</span><span class="nx">Neutral</span><span class="o">&lt;</span><span class="err">/b&gt;);}</span>
        <span class="k">else</span> <span class="k">if</span><span class="p">(</span><span class="nx">props</span><span class="p">.</span><span class="nx">value</span> <span class="o">===</span> <span class="mf">4</span><span class="p">){</span>
            <span class="k">return</span> <span class="p">(</span><span class="o">&lt;</span><span class="nx">b</span><span class="o">&gt;</span><span class="nx">Good</span><span class="o">&lt;</span><span class="err">/b&gt;);}</span>
        <span class="k">else</span> <span class="p">{</span>
            <span class="k">return</span> <span class="p">(</span><span class="o">&lt;</span><span class="nx">b</span><span class="o">&gt;</span><span class="nx">Happy</span><span class="o">&lt;</span><span class="err">/b&gt;);}</span>
    <span class="p">}</span>
  
    <span class="k">return</span> <span class="p">(</span>
        <span class="o">&lt;</span><span class="nx">div</span> <span class="nx">className</span><span class="o">=</span><span class="s1">'wrap'</span><span class="o">&gt;</span>
            <span class="o">&lt;</span><span class="nx">RatingComponent</span> <span class="nx">id</span><span class="o">=</span><span class="s1">'rating'</span> <span class="nx">showTooltip</span><span class="o">=</span><span class="p">{</span><span class="kc">true</span><span class="p">}</span> <span class="nx">value</span><span class="o">=</span><span class="p">{</span><span class="mf">3</span><span class="p">}</span> <span class="nx">tooltipTemplate</span><span class="o">=</span><span class="p">{</span><span class="nx">tooltipTemplate</span><span class="p">}</span> <span class="o">&gt;&lt;</span><span class="err">/RatingComponent&gt;</span>
        <span class="o">&lt;</span><span class="err">/div&gt;</span>
    <span class="p">);</span>
<span class="p">}</span>
<span class="k">export</span> <span class="k">default</span> <span class="nx">App</span><span class="p">;</span>
<span class="nx">ReactDom</span><span class="p">.</span><span class="nx">render</span><span class="p">(</span><span class="o">&lt;</span><span class="nx">App</span> <span class="o">/&gt;</span><span class="p">,</span><span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="s1">'element'</span><span class="p">));</span></code></pre></div>
</div>

</div>

</div>

<p><button class="preview-sample-button" id="PreviewSampleButton-rks1aag7xch7axcvy1s11f80vy7hlu0c" onclick="LoadPreviewSample('https://ej2.syncfusion.com/react/documentation/code-snippet/rating/tooltip/tooltip-template-cs1',this.id);">Preview Sample</button><button class="stackblitz-button" id="StackBlitzButton-rks1aag7xch7axcvy1s11f80vy7hlu0c" onclick="OpenSampleInStackBlitz('https://ej2.syncfusion.com/react/documentation/code-snippet/rating/tooltip/tooltip-template-cs1');"><img class="stackblitz-icon" src="https://cdn.syncfusion.com/documentation/images/StackBlitz-icon.png"><span class="stackblitz-text">Open in Stackblitz</span></button></p>
<div id="PreviewSampleHolder-rks1aag7xch7axcvy1s11f80vy7hlu0c"></div>

<h2 id="tooltip-customization">Tooltip customization</h2>

<p>You can customize the appearance of the tooltips using the <code>cssClass</code> property of the rating component and by defining the custom styles for tooltip elements like the below example.</p>

<blockquote>
  <p>You can find more information about customizing the appearance of the tooltip in the <a href="https://ej2.syncfusion.com/react/documentation/tooltip/style/">Tooltip Customization</a> documentation.</p>
</blockquote>

<div class="tabs" id="code-snippet-3">

<ul class="nav nav-tabs" role="tablist">

<li role="presentation" class=""><a data-target="#2bwj3rbta2k6j07fyg97q3kp9uu4l1f3-js" aria-controls="home" role="tab" data-toggle="tab" data-original-lang="js">index.jsx</a></li>
<li role="presentation" class=""><a data-target="#pyrpw0fzkuci9lbs9gdb2wtvnm3m6hio-ts" aria-controls="home" role="tab" data-toggle="tab" data-original-lang="ts">index.tsx</a></li>
<li role="presentation" class=""><a data-target="#8maqbq35304e8d1c9gihyflcyj827o90-ts" aria-controls="home" role="tab" data-toggle="tab" data-original-lang="ts">styles.css</a></li>

</ul>

<div class="tab-content">


<div role="tabpanel" class="tab-pane" id="2bwj3rbta2k6j07fyg97q3kp9uu4l1f3-js" data-original-lang="js">
<div class="highlight"><pre><code class="prettyprint language-js" data-lang="js"><span></span><span class="c1">// Import the Rating.</span>
<span class="k">import</span> <span class="p">{</span> <span class="nx">RatingComponent</span> <span class="p">}</span> <span class="kr">from</span> <span class="s1">'@syncfusion/ej2-react-inputs'</span><span class="p">;</span>
<span class="k">import</span> <span class="o">*</span> <span class="kr">as</span> <span class="nx">React</span> <span class="kr">from</span> <span class="s1">'react'</span><span class="p">;</span>
<span class="k">import</span> <span class="o">*</span> <span class="kr">as</span> <span class="nx">ReactDom</span> <span class="kr">from</span> <span class="s1">'react-dom'</span><span class="p">;</span>
<span class="c1">// To render Rating.</span>
<span class="kd">function</span> <span class="nx">App</span><span class="p">()</span> <span class="p">{</span>
    <span class="k">return</span> <span class="p">(</span><span class="o">&lt;</span><span class="nx">div</span> <span class="nx">className</span><span class="o">=</span><span class="s1">'wrap'</span><span class="o">&gt;</span>
          <span class="o">&lt;</span><span class="nx">RatingComponent</span> <span class="nx">id</span><span class="o">=</span><span class="s1">'rating'</span> <span class="nx">showTooltip</span><span class="o">=</span><span class="p">{</span><span class="kc">true</span><span class="p">}</span> <span class="nx">value</span><span class="o">=</span><span class="p">{</span><span class="mf">3</span><span class="p">}</span> <span class="nx">cssClass</span><span class="o">=</span><span class="s1">'customtooltip'</span><span class="o">&gt;&lt;</span><span class="err">/RatingComponent&gt;</span>
      <span class="o">&lt;</span><span class="err">/div&gt;);</span>
<span class="p">}</span>
<span class="k">export</span> <span class="k">default</span> <span class="nx">App</span><span class="p">;</span>
<span class="nx">ReactDom</span><span class="p">.</span><span class="nx">render</span><span class="p">(</span><span class="o">&lt;</span><span class="nx">App</span> <span class="o">/&gt;</span><span class="p">,</span> <span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="s1">'element'</span><span class="p">));</span></code></pre></div>
</div>

<div role="tabpanel" class="tab-pane" id="pyrpw0fzkuci9lbs9gdb2wtvnm3m6hio-ts" data-original-lang="ts">
<div class="highlight"><pre><code class="prettyprint language-ts" data-lang="ts"><span></span><span class="c1">// Import the Rating.</span>
<span class="k">import</span> <span class="p">{</span> <span class="nx">RatingComponent</span> <span class="p">}</span> <span class="kr">from</span> <span class="s1">'@syncfusion/ej2-react-inputs'</span><span class="p">;</span>
<span class="k">import</span> <span class="o">*</span> <span class="kr">as</span> <span class="nx">React</span> <span class="kr">from</span> <span class="s1">'react'</span><span class="p">;</span>
<span class="k">import</span> <span class="o">*</span> <span class="kr">as</span> <span class="nx">ReactDom</span> <span class="kr">from</span> <span class="s1">'react-dom'</span><span class="p">;</span>

<span class="c1">// To render Rating.</span>
<span class="kd">function</span> <span class="nx">App</span><span class="p">()</span> <span class="p">{</span>
  
    <span class="k">return</span> <span class="p">(</span>
        <span class="o">&lt;</span><span class="nx">div</span> <span class="nx">className</span><span class="o">=</span><span class="s1">'wrap'</span><span class="o">&gt;</span>
            <span class="o">&lt;</span><span class="nx">RatingComponent</span> <span class="nx">id</span><span class="o">=</span><span class="s1">'rating'</span> <span class="nx">showTooltip</span><span class="o">=</span><span class="p">{</span><span class="kc">true</span><span class="p">}</span> <span class="nx">value</span><span class="o">=</span><span class="p">{</span><span class="mf">3</span><span class="p">}</span> <span class="nx">cssClass</span><span class="o">=</span><span class="s1">'customtooltip'</span> <span class="o">&gt;&lt;</span><span class="err">/RatingComponent&gt;</span>
        <span class="o">&lt;</span><span class="err">/div&gt;</span>
    <span class="p">);</span>
<span class="p">}</span>
<span class="k">export</span> <span class="k">default</span> <span class="nx">App</span><span class="p">;</span>
<span class="nx">ReactDom</span><span class="p">.</span><span class="nx">render</span><span class="p">(</span><span class="o">&lt;</span><span class="nx">App</span> <span class="o">/&gt;</span><span class="p">,</span><span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="s1">'element'</span><span class="p">));</span></code></pre></div>
</div>

<div role="tabpanel" class="tab-pane" id="8maqbq35304e8d1c9gihyflcyj827o90-ts" data-original-lang="ts">
<div class="highlight"><pre><code class="prettyprint language-ts" data-lang="ts"><span></span><span class="cm">/* Represents the styles for loader */</span>
<span class="err">#</span><span class="nx">loader</span> <span class="p">{</span>
    <span class="nx">color</span><span class="o">:</span> <span class="err">#</span><span class="mo">00</span><span class="mf">8</span><span class="nx">cff</span><span class="p">;</span>
    <span class="nx">font</span><span class="o">-</span><span class="nx">family</span><span class="o">:</span> <span class="s1">'Helvetica Neue'</span><span class="p">,</span> <span class="s1">'calibiri'</span><span class="p">;</span>
    <span class="nx">font</span><span class="o">-</span><span class="nx">size</span>: <span class="kt">14px</span><span class="p">;</span>
    <span class="nx">height</span>: <span class="kt">40px</span><span class="p">;</span>
    <span class="nx">left</span>: <span class="kt">45</span><span class="o">%</span><span class="p">;</span>
    <span class="nx">position</span>: <span class="kt">absolute</span><span class="p">;</span>
    <span class="nx">top</span>: <span class="kt">45</span><span class="o">%</span><span class="p">;</span>
    <span class="nx">width</span>: <span class="kt">30</span><span class="o">%</span><span class="p">;</span>
<span class="p">}</span>

<span class="p">.</span><span class="nx">wrap</span> <span class="p">{</span>
    <span class="nx">margin</span>: <span class="kt">50px</span> <span class="nx">auto</span><span class="p">;</span>
    <span class="nx">text</span><span class="o">-</span><span class="nx">align</span>: <span class="kt">center</span><span class="p">;</span>
<span class="p">}</span>

<span class="cm">/* To change the radius of the tooltip corners. */</span>
<span class="p">.</span><span class="nx">customtooltip</span><span class="p">.</span><span class="nx">e</span><span class="o">-</span><span class="nx">tooltip</span><span class="o">-</span><span class="nx">wrap</span> <span class="p">{</span>
  <span class="nx">border</span><span class="o">-</span><span class="nx">radius</span>: <span class="kt">3px</span><span class="p">;</span>
<span class="p">}</span>

<span class="cm">/* To change the size of the tooltip content. */</span>
<span class="p">.</span><span class="nx">customtooltip</span><span class="p">.</span><span class="nx">e</span><span class="o">-</span><span class="nx">tooltip</span><span class="o">-</span><span class="nx">wrap</span> <span class="p">.</span><span class="nx">e</span><span class="o">-</span><span class="nx">tip</span><span class="o">-</span><span class="nx">content</span> <span class="p">{</span>
  <span class="nx">font</span><span class="o">-</span><span class="nx">size</span>:<span class="kt">14px</span><span class="p">;</span>
<span class="p">}</span>

<span class="cm">/* To change the border color and width for tooltip. */</span>
<span class="p">.</span><span class="nx">customtooltip</span><span class="p">.</span><span class="nx">e</span><span class="o">-</span><span class="nx">tooltip</span><span class="o">-</span><span class="nx">wrap</span><span class="p">.</span><span class="nx">e</span><span class="o">-</span><span class="nx">popup</span> <span class="p">{</span>
  <span class="nx">border</span>: <span class="kt">2px</span> <span class="nx">solid</span> <span class="err">#</span><span class="mo">000000</span><span class="p">;</span>
<span class="p">}</span>

<span class="cm">/* To change the color for arrow of the tooltip. */</span>
<span class="p">.</span><span class="nx">customtooltip</span><span class="p">.</span><span class="nx">e</span><span class="o">-</span><span class="nx">tooltip</span><span class="o">-</span><span class="nx">wrap</span> <span class="p">.</span><span class="nx">e</span><span class="o">-</span><span class="nx">arrow</span><span class="o">-</span><span class="nx">tip</span><span class="o">-</span><span class="nx">inner</span><span class="p">.</span><span class="nx">e</span><span class="o">-</span><span class="nx">tip</span><span class="o">-</span><span class="nx">bottom</span> <span class="p">{</span>
  <span class="nx">border</span>: <span class="kt">12px</span> <span class="err">#</span><span class="mf">9693</span>
<span class="p">}</span>

<span class="cm">/* To change the top border color for arrow of the tooltip. */</span>
<span class="p">.</span><span class="nx">customtooltip</span><span class="p">.</span><span class="nx">e</span><span class="o">-</span><span class="nx">tooltip</span><span class="o">-</span><span class="nx">wrap</span> <span class="p">.</span><span class="nx">e</span><span class="o">-</span><span class="nx">arrow</span><span class="o">-</span><span class="nx">tip</span><span class="o">-</span><span class="nx">outer</span><span class="p">.</span><span class="nx">e</span><span class="o">-</span><span class="nx">tip</span><span class="o">-</span><span class="nx">bottom</span> <span class="p">{</span>
  <span class="nx">border</span><span class="o">-</span><span class="nx">top</span>: <span class="kt">9.5px</span> <span class="nx">solid</span> <span class="err">#</span><span class="mo">000000</span><span class="p">;</span>
<span class="p">}</span></code></pre></div>
</div>

</div>

</div>

<p><button class="preview-sample-button" id="PreviewSampleButton-q43a5q9g041jvllkj3afg6a1zjvivnip" onclick="LoadPreviewSample('https://ej2.syncfusion.com/react/documentation/code-snippet/rating/tooltip/custom-tooltip-cs1',this.id);">Preview Sample</button><button class="stackblitz-button" id="StackBlitzButton-q43a5q9g041jvllkj3afg6a1zjvivnip" onclick="OpenSampleInStackBlitz('https://ej2.syncfusion.com/react/documentation/code-snippet/rating/tooltip/custom-tooltip-cs1');"><img class="stackblitz-icon" src="https://cdn.syncfusion.com/documentation/images/StackBlitz-icon.png"><span class="stackblitz-text">Open in Stackblitz</span></button></p>
<div id="PreviewSampleHolder-q43a5q9g041jvllkj3afg6a1zjvivnip"></div>

    />);
}
const root = ReactDOM.createRoot(document.getElementById('diagram'));
root.render(<App />);
import * as React from "react";
import * as ReactDOM from "react-dom";
import { DiagramComponent, DiagramConstraints, NodeConstraints,ConnectorConstraints,NodeModel, } from "@syncfusion/ej2-react-diagrams";
// A node is created and stored in nodes array.
let node:NodeModel[] = [{
        id: "node1",
        width: 100,
        height: 100,
        annotations: [{
                id: 'label',
                content: 'Rectangle',
                offset: {
                    x: 0.5,
                    y: 0.5
                },
                style: {
                    color: 'white'
                },
            }],
        offsetX: 200,
        offsetY: 200,
        style: {
            strokeColor: '#6BA5D7',
            fill: '#6BA5D7'
        },
        constraints: NodeConstraints.Default | NodeConstraints.Tooltip,
        //Defines mouse over tooltip for a node
        tooltip: {
            //Sets the content of the Tooltip
            content: 'Node1'
        },
    }];
let connector = [{
    id: 'connector1',
    sourcePoint: { x: 300, y: 100 },
    targetPoint: { x: 400, y: 250 },
    tooltip: { content: 'connector' },
    constraints: ConnectorConstraints.Default | ConnectorConstraints.Tooltip, 
}]
//Initializes the Diagram component
function App() {
    return (<DiagramComponent id="container" width={'650px'} height={'350px'} constraints={DiagramConstraints.Default | DiagramConstraints.Tooltip} 
    //Defines nodes
    nodes={node} connectors={connector}
     //Defines mouse over tooltip for a node
     tooltip=<h1 id="tooltip-in-react-rating-component">Tooltip in React Rating Component</h1>

<p>The rating component supports tooltip to show additional information in rating items by setting the <a href="https://ej2.syncfusion.com/react/documentation/api/rating/#showtooltip"><code>showTooltip</code></a> property. If enabled, the tooltip appears when the user hovers over a rating item.</p>

<div class="tabs" id="code-snippet-1">

<ul class="nav nav-tabs" role="tablist">

<li role="presentation" class=""><a data-target="#dl6n7q0wcfe3woaocdpcs4eeubtvccyp-js" aria-controls="home" role="tab" data-toggle="tab" data-original-lang="js">index.jsx</a></li>
<li role="presentation" class=""><a data-target="#tusza991sr0e577o4xm26tri68d612h3-ts" aria-controls="home" role="tab" data-toggle="tab" data-original-lang="ts">index.tsx</a></li>

</ul>

<div class="tab-content">


<div role="tabpanel" class="tab-pane" id="dl6n7q0wcfe3woaocdpcs4eeubtvccyp-js" data-original-lang="js">
<div class="highlight"><pre><code class="prettyprint language-js" data-lang="js"><span></span><span class="c1">// Import the Rating.</span>
<span class="k">import</span> <span class="p">{</span> <span class="nx">RatingComponent</span> <span class="p">}</span> <span class="kr">from</span> <span class="s1">'@syncfusion/ej2-react-inputs'</span><span class="p">;</span>
<span class="k">import</span> <span class="o">*</span> <span class="kr">as</span> <span class="nx">React</span> <span class="kr">from</span> <span class="s1">'react'</span><span class="p">;</span>
<span class="k">import</span> <span class="o">*</span> <span class="kr">as</span> <span class="nx">ReactDom</span> <span class="kr">from</span> <span class="s1">'react-dom'</span><span class="p">;</span>
<span class="c1">// To render Rating.</span>
<span class="kd">function</span> <span class="nx">App</span><span class="p">()</span> <span class="p">{</span>
    <span class="k">return</span> <span class="p">(</span><span class="o">&lt;</span><span class="nx">div</span> <span class="nx">className</span><span class="o">=</span><span class="s1">'wrap'</span><span class="o">&gt;</span>
            <span class="o">&lt;</span><span class="nx">RatingComponent</span> <span class="nx">id</span><span class="o">=</span><span class="s1">'rating'</span> <span class="nx">showTooltip</span><span class="o">=</span><span class="p">{</span><span class="kc">true</span><span class="p">}</span> <span class="nx">value</span><span class="o">=</span><span class="p">{</span><span class="mf">3</span><span class="p">}</span><span class="o">&gt;&lt;</span><span class="err">/RatingComponent&gt;</span>
        <span class="o">&lt;</span><span class="err">/div&gt;);</span>
<span class="p">}</span>
<span class="k">export</span> <span class="k">default</span> <span class="nx">App</span><span class="p">;</span>
<span class="nx">ReactDom</span><span class="p">.</span><span class="nx">render</span><span class="p">(</span><span class="o">&lt;</span><span class="nx">App</span> <span class="o">/&gt;</span><span class="p">,</span> <span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="s1">'element'</span><span class="p">));</span></code></pre></div>
</div>

<div role="tabpanel" class="tab-pane" id="tusza991sr0e577o4xm26tri68d612h3-ts" data-original-lang="ts">
<div class="highlight"><pre><code class="prettyprint language-ts" data-lang="ts"><span></span><span class="c1">// Import the Rating.</span>
<span class="k">import</span> <span class="p">{</span> <span class="nx">RatingComponent</span> <span class="p">}</span> <span class="kr">from</span> <span class="s1">'@syncfusion/ej2-react-inputs'</span><span class="p">;</span>
<span class="k">import</span> <span class="o">*</span> <span class="kr">as</span> <span class="nx">React</span> <span class="kr">from</span> <span class="s1">'react'</span><span class="p">;</span>
<span class="k">import</span> <span class="o">*</span> <span class="kr">as</span> <span class="nx">ReactDom</span> <span class="kr">from</span> <span class="s1">'react-dom'</span><span class="p">;</span>

<span class="c1">// To render Rating.</span>
<span class="kd">function</span> <span class="nx">App</span><span class="p">()</span> <span class="p">{</span>
  
    <span class="k">return</span> <span class="p">(</span>
        <span class="o">&lt;</span><span class="nx">div</span> <span class="nx">className</span><span class="o">=</span><span class="s1">'wrap'</span><span class="o">&gt;</span>
            <span class="o">&lt;</span><span class="nx">RatingComponent</span> <span class="nx">id</span><span class="o">=</span><span class="s1">'rating'</span> <span class="nx">showTooltip</span><span class="o">=</span><span class="p">{</span><span class="kc">true</span><span class="p">}</span> <span class="nx">value</span><span class="o">=</span><span class="p">{</span><span class="mf">3</span><span class="p">}</span> <span class="o">&gt;&lt;</span><span class="err">/RatingComponent&gt;</span>
        <span class="o">&lt;</span><span class="err">/div&gt;</span>
    <span class="p">);</span>
<span class="p">}</span>
<span class="k">export</span> <span class="k">default</span> <span class="nx">App</span><span class="p">;</span>
<span class="nx">ReactDom</span><span class="p">.</span><span class="nx">render</span><span class="p">(</span><span class="o">&lt;</span><span class="nx">App</span> <span class="o">/&gt;</span><span class="p">,</span><span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="s1">'element'</span><span class="p">));</span></code></pre></div>
</div>

</div>

</div>

<p><button class="preview-sample-button" id="PreviewSampleButton-e3g1gt0u2ngxfewkudkqwdg8zoe3grie" onclick="LoadPreviewSample('https://ej2.syncfusion.com/react/documentation/code-snippet/rating/tooltip/showtooltip-cs1',this.id);">Preview Sample</button><button class="stackblitz-button" id="StackBlitzButton-e3g1gt0u2ngxfewkudkqwdg8zoe3grie" onclick="OpenSampleInStackBlitz('https://ej2.syncfusion.com/react/documentation/code-snippet/rating/tooltip/showtooltip-cs1');"><img class="stackblitz-icon" src="https://cdn.syncfusion.com/documentation/images/StackBlitz-icon.png"><span class="stackblitz-text">Open in Stackblitz</span></button></p>
<div id="PreviewSampleHolder-e3g1gt0u2ngxfewkudkqwdg8zoe3grie"></div>

<h2 id="tooltip-template">Tooltip template</h2>

<p>You can use the <a href="https://ej2.syncfusion.com/react/documentation/api/rating/#tooltiptemplate"><code>tooltipTemplate</code></a> tag directive to specify a custom template for the <code>tooltip</code> of the rating. The current value of the rating will be passed as the <code>value</code> property in the template context when building the content of the tooltip. This allows you to include dynamic information about the rating in the template.</p>

<div class="tabs" id="code-snippet-2">

<ul class="nav nav-tabs" role="tablist">

<li role="presentation" class=""><a data-target="#v32y668atapfui31ufmv4kqjutfnni84-js" aria-controls="home" role="tab" data-toggle="tab" data-original-lang="js">index.jsx</a></li>
<li role="presentation" class=""><a data-target="#8k84637upqqbghwln32l3m2f01jvj1fg-ts" aria-controls="home" role="tab" data-toggle="tab" data-original-lang="ts">index.tsx</a></li>

</ul>

<div class="tab-content">


<div role="tabpanel" class="tab-pane" id="v32y668atapfui31ufmv4kqjutfnni84-js" data-original-lang="js">
<div class="highlight"><pre><code class="prettyprint language-js" data-lang="js"><span></span><span class="c1">// Import the Rating.</span>
<span class="k">import</span> <span class="p">{</span> <span class="nx">RatingComponent</span> <span class="p">}</span> <span class="kr">from</span> <span class="s1">'@syncfusion/ej2-react-inputs'</span><span class="p">;</span>
<span class="k">import</span> <span class="o">*</span> <span class="kr">as</span> <span class="nx">React</span> <span class="kr">from</span> <span class="s1">'react'</span><span class="p">;</span>
<span class="k">import</span> <span class="o">*</span> <span class="kr">as</span> <span class="nx">ReactDom</span> <span class="kr">from</span> <span class="s1">'react-dom'</span><span class="p">;</span>
<span class="c1">// To render Rating.</span>
<span class="kd">function</span> <span class="nx">App</span><span class="p">()</span> <span class="p">{</span>
    <span class="kd">function</span> <span class="nx">tooltipTemplate</span><span class="p">(</span><span class="nx">props</span><span class="p">)</span> <span class="p">{</span>
        <span class="k">if</span> <span class="p">(</span><span class="nx">props</span><span class="p">.</span><span class="nx">value</span> <span class="o">===</span> <span class="mf">1</span><span class="p">)</span> <span class="p">{</span>
            <span class="k">return</span> <span class="p">(</span><span class="o">&lt;</span><span class="nx">b</span><span class="o">&gt;</span><span class="nx">Angry</span><span class="o">&lt;</span><span class="err">/b&gt;);</span>
        <span class="p">}</span>
        <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="nx">props</span><span class="p">.</span><span class="nx">value</span> <span class="o">===</span> <span class="mf">2</span><span class="p">)</span> <span class="p">{</span>
            <span class="k">return</span> <span class="p">(</span><span class="o">&lt;</span><span class="nx">b</span><span class="o">&gt;</span><span class="nx">Sad</span><span class="o">&lt;</span><span class="err">/b&gt;);</span>
        <span class="p">}</span>
        <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="nx">props</span><span class="p">.</span><span class="nx">value</span> <span class="o">===</span> <span class="mf">3</span><span class="p">)</span> <span class="p">{</span>
            <span class="k">return</span> <span class="p">(</span><span class="o">&lt;</span><span class="nx">b</span><span class="o">&gt;</span><span class="nx">Neutral</span><span class="o">&lt;</span><span class="err">/b&gt;);</span>
        <span class="p">}</span>
        <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="nx">props</span><span class="p">.</span><span class="nx">value</span> <span class="o">===</span> <span class="mf">4</span><span class="p">)</span> <span class="p">{</span>
            <span class="k">return</span> <span class="p">(</span><span class="o">&lt;</span><span class="nx">b</span><span class="o">&gt;</span><span class="nx">Good</span><span class="o">&lt;</span><span class="err">/b&gt;);</span>
        <span class="p">}</span>
        <span class="k">else</span> <span class="p">{</span>
            <span class="k">return</span> <span class="p">(</span><span class="o">&lt;</span><span class="nx">b</span><span class="o">&gt;</span><span class="nx">Happy</span><span class="o">&lt;</span><span class="err">/b&gt;);</span>
        <span class="p">}</span>
    <span class="p">}</span>
    <span class="k">return</span> <span class="p">(</span><span class="o">&lt;</span><span class="nx">div</span> <span class="nx">className</span><span class="o">=</span><span class="s1">'wrap'</span><span class="o">&gt;</span>
          <span class="o">&lt;</span><span class="nx">RatingComponent</span> <span class="nx">id</span><span class="o">=</span><span class="s1">'rating'</span> <span class="nx">showTooltip</span><span class="o">=</span><span class="p">{</span><span class="kc">true</span><span class="p">}</span> <span class="nx">value</span><span class="o">=</span><span class="p">{</span><span class="mf">3</span><span class="p">}</span> <span class="nx">tooltipTemplate</span><span class="o">=</span><span class="p">{</span><span class="nx">tooltipTemplate</span><span class="p">}</span><span class="o">&gt;&lt;</span><span class="err">/RatingComponent&gt;</span>
      <span class="o">&lt;</span><span class="err">/div&gt;);</span>
<span class="p">}</span>
<span class="k">export</span> <span class="k">default</span> <span class="nx">App</span><span class="p">;</span>
<span class="nx">ReactDom</span><span class="p">.</span><span class="nx">render</span><span class="p">(</span><span class="o">&lt;</span><span class="nx">App</span> <span class="o">/&gt;</span><span class="p">,</span> <span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="s1">'element'</span><span class="p">));</span></code></pre></div>
</div>

<div role="tabpanel" class="tab-pane" id="8k84637upqqbghwln32l3m2f01jvj1fg-ts" data-original-lang="ts">
<div class="highlight"><pre><code class="prettyprint language-ts" data-lang="ts"><span></span><span class="c1">// Import the Rating.</span>
<span class="k">import</span> <span class="p">{</span> <span class="nx">RatingComponent</span> <span class="p">}</span> <span class="kr">from</span> <span class="s1">'@syncfusion/ej2-react-inputs'</span><span class="p">;</span>
<span class="k">import</span> <span class="o">*</span> <span class="kr">as</span> <span class="nx">React</span> <span class="kr">from</span> <span class="s1">'react'</span><span class="p">;</span>
<span class="k">import</span> <span class="o">*</span> <span class="kr">as</span> <span class="nx">ReactDom</span> <span class="kr">from</span> <span class="s1">'react-dom'</span><span class="p">;</span>

<span class="c1">// To render Rating.</span>
<span class="kd">function</span> <span class="nx">App</span><span class="p">()</span> <span class="p">{</span>

    <span class="kd">function</span> <span class="nx">tooltipTemplate</span><span class="p">(</span><span class="nx">props</span>: <span class="kt">any</span><span class="p">)</span> <span class="p">{</span>
        <span class="k">if</span><span class="p">(</span><span class="nx">props</span><span class="p">.</span><span class="nx">value</span> <span class="o">===</span> <span class="mf">1</span><span class="p">){</span>
            <span class="k">return</span> <span class="p">(</span><span class="o">&lt;</span><span class="nx">b</span><span class="o">&gt;</span><span class="nx">Angry</span><span class="o">&lt;</span><span class="err">/b&gt;);}</span>
        <span class="k">else</span> <span class="k">if</span><span class="p">(</span><span class="nx">props</span><span class="p">.</span><span class="nx">value</span> <span class="o">===</span> <span class="mf">2</span><span class="p">){</span>
            <span class="k">return</span> <span class="p">(</span><span class="o">&lt;</span><span class="nx">b</span><span class="o">&gt;</span><span class="nx">Sad</span><span class="o">&lt;</span><span class="err">/b&gt;);}</span>
        <span class="k">else</span> <span class="k">if</span><span class="p">(</span><span class="nx">props</span><span class="p">.</span><span class="nx">value</span> <span class="o">===</span> <span class="mf">3</span><span class="p">){</span>
            <span class="k">return</span> <span class="p">(</span><span class="o">&lt;</span><span class="nx">b</span><span class="o">&gt;</span><span class="nx">Neutral</span><span class="o">&lt;</span><span class="err">/b&gt;);}</span>
        <span class="k">else</span> <span class="k">if</span><span class="p">(</span><span class="nx">props</span><span class="p">.</span><span class="nx">value</span> <span class="o">===</span> <span class="mf">4</span><span class="p">){</span>
            <span class="k">return</span> <span class="p">(</span><span class="o">&lt;</span><span class="nx">b</span><span class="o">&gt;</span><span class="nx">Good</span><span class="o">&lt;</span><span class="err">/b&gt;);}</span>
        <span class="k">else</span> <span class="p">{</span>
            <span class="k">return</span> <span class="p">(</span><span class="o">&lt;</span><span class="nx">b</span><span class="o">&gt;</span><span class="nx">Happy</span><span class="o">&lt;</span><span class="err">/b&gt;);}</span>
    <span class="p">}</span>
  
    <span class="k">return</span> <span class="p">(</span>
        <span class="o">&lt;</span><span class="nx">div</span> <span class="nx">className</span><span class="o">=</span><span class="s1">'wrap'</span><span class="o">&gt;</span>
            <span class="o">&lt;</span><span class="nx">RatingComponent</span> <span class="nx">id</span><span class="o">=</span><span class="s1">'rating'</span> <span class="nx">showTooltip</span><span class="o">=</span><span class="p">{</span><span class="kc">true</span><span class="p">}</span> <span class="nx">value</span><span class="o">=</span><span class="p">{</span><span class="mf">3</span><span class="p">}</span> <span class="nx">tooltipTemplate</span><span class="o">=</span><span class="p">{</span><span class="nx">tooltipTemplate</span><span class="p">}</span> <span class="o">&gt;&lt;</span><span class="err">/RatingComponent&gt;</span>
        <span class="o">&lt;</span><span class="err">/div&gt;</span>
    <span class="p">);</span>
<span class="p">}</span>
<span class="k">export</span> <span class="k">default</span> <span class="nx">App</span><span class="p">;</span>
<span class="nx">ReactDom</span><span class="p">.</span><span class="nx">render</span><span class="p">(</span><span class="o">&lt;</span><span class="nx">App</span> <span class="o">/&gt;</span><span class="p">,</span><span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="s1">'element'</span><span class="p">));</span></code></pre></div>
</div>

</div>

</div>

<p><button class="preview-sample-button" id="PreviewSampleButton-rks1aag7xch7axcvy1s11f80vy7hlu0c" onclick="LoadPreviewSample('https://ej2.syncfusion.com/react/documentation/code-snippet/rating/tooltip/tooltip-template-cs1',this.id);">Preview Sample</button><button class="stackblitz-button" id="StackBlitzButton-rks1aag7xch7axcvy1s11f80vy7hlu0c" onclick="OpenSampleInStackBlitz('https://ej2.syncfusion.com/react/documentation/code-snippet/rating/tooltip/tooltip-template-cs1');"><img class="stackblitz-icon" src="https://cdn.syncfusion.com/documentation/images/StackBlitz-icon.png"><span class="stackblitz-text">Open in Stackblitz</span></button></p>
<div id="PreviewSampleHolder-rks1aag7xch7axcvy1s11f80vy7hlu0c"></div>

<h2 id="tooltip-customization">Tooltip customization</h2>

<p>You can customize the appearance of the tooltips using the <code>cssClass</code> property of the rating component and by defining the custom styles for tooltip elements like the below example.</p>

<blockquote>
  <p>You can find more information about customizing the appearance of the tooltip in the <a href="https://ej2.syncfusion.com/react/documentation/tooltip/style/">Tooltip Customization</a> documentation.</p>
</blockquote>

<div class="tabs" id="code-snippet-3">

<ul class="nav nav-tabs" role="tablist">

<li role="presentation" class=""><a data-target="#2bwj3rbta2k6j07fyg97q3kp9uu4l1f3-js" aria-controls="home" role="tab" data-toggle="tab" data-original-lang="js">index.jsx</a></li>
<li role="presentation" class=""><a data-target="#pyrpw0fzkuci9lbs9gdb2wtvnm3m6hio-ts" aria-controls="home" role="tab" data-toggle="tab" data-original-lang="ts">index.tsx</a></li>
<li role="presentation" class=""><a data-target="#8maqbq35304e8d1c9gihyflcyj827o90-ts" aria-controls="home" role="tab" data-toggle="tab" data-original-lang="ts">styles.css</a></li>

</ul>

<div class="tab-content">


<div role="tabpanel" class="tab-pane" id="2bwj3rbta2k6j07fyg97q3kp9uu4l1f3-js" data-original-lang="js">
<div class="highlight"><pre><code class="prettyprint language-js" data-lang="js"><span></span><span class="c1">// Import the Rating.</span>
<span class="k">import</span> <span class="p">{</span> <span class="nx">RatingComponent</span> <span class="p">}</span> <span class="kr">from</span> <span class="s1">'@syncfusion/ej2-react-inputs'</span><span class="p">;</span>
<span class="k">import</span> <span class="o">*</span> <span class="kr">as</span> <span class="nx">React</span> <span class="kr">from</span> <span class="s1">'react'</span><span class="p">;</span>
<span class="k">import</span> <span class="o">*</span> <span class="kr">as</span> <span class="nx">ReactDom</span> <span class="kr">from</span> <span class="s1">'react-dom'</span><span class="p">;</span>
<span class="c1">// To render Rating.</span>
<span class="kd">function</span> <span class="nx">App</span><span class="p">()</span> <span class="p">{</span>
    <span class="k">return</span> <span class="p">(</span><span class="o">&lt;</span><span class="nx">div</span> <span class="nx">className</span><span class="o">=</span><span class="s1">'wrap'</span><span class="o">&gt;</span>
          <span class="o">&lt;</span><span class="nx">RatingComponent</span> <span class="nx">id</span><span class="o">=</span><span class="s1">'rating'</span> <span class="nx">showTooltip</span><span class="o">=</span><span class="p">{</span><span class="kc">true</span><span class="p">}</span> <span class="nx">value</span><span class="o">=</span><span class="p">{</span><span class="mf">3</span><span class="p">}</span> <span class="nx">cssClass</span><span class="o">=</span><span class="s1">'customtooltip'</span><span class="o">&gt;&lt;</span><span class="err">/RatingComponent&gt;</span>
      <span class="o">&lt;</span><span class="err">/div&gt;);</span>
<span class="p">}</span>
<span class="k">export</span> <span class="k">default</span> <span class="nx">App</span><span class="p">;</span>
<span class="nx">ReactDom</span><span class="p">.</span><span class="nx">render</span><span class="p">(</span><span class="o">&lt;</span><span class="nx">App</span> <span class="o">/&gt;</span><span class="p">,</span> <span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="s1">'element'</span><span class="p">));</span></code></pre></div>
</div>

<div role="tabpanel" class="tab-pane" id="pyrpw0fzkuci9lbs9gdb2wtvnm3m6hio-ts" data-original-lang="ts">
<div class="highlight"><pre><code class="prettyprint language-ts" data-lang="ts"><span></span><span class="c1">// Import the Rating.</span>
<span class="k">import</span> <span class="p">{</span> <span class="nx">RatingComponent</span> <span class="p">}</span> <span class="kr">from</span> <span class="s1">'@syncfusion/ej2-react-inputs'</span><span class="p">;</span>
<span class="k">import</span> <span class="o">*</span> <span class="kr">as</span> <span class="nx">React</span> <span class="kr">from</span> <span class="s1">'react'</span><span class="p">;</span>
<span class="k">import</span> <span class="o">*</span> <span class="kr">as</span> <span class="nx">ReactDom</span> <span class="kr">from</span> <span class="s1">'react-dom'</span><span class="p">;</span>

<span class="c1">// To render Rating.</span>
<span class="kd">function</span> <span class="nx">App</span><span class="p">()</span> <span class="p">{</span>
  
    <span class="k">return</span> <span class="p">(</span>
        <span class="o">&lt;</span><span class="nx">div</span> <span class="nx">className</span><span class="o">=</span><span class="s1">'wrap'</span><span class="o">&gt;</span>
            <span class="o">&lt;</span><span class="nx">RatingComponent</span> <span class="nx">id</span><span class="o">=</span><span class="s1">'rating'</span> <span class="nx">showTooltip</span><span class="o">=</span><span class="p">{</span><span class="kc">true</span><span class="p">}</span> <span class="nx">value</span><span class="o">=</span><span class="p">{</span><span class="mf">3</span><span class="p">}</span> <span class="nx">cssClass</span><span class="o">=</span><span class="s1">'customtooltip'</span> <span class="o">&gt;&lt;</span><span class="err">/RatingComponent&gt;</span>
        <span class="o">&lt;</span><span class="err">/div&gt;</span>
    <span class="p">);</span>
<span class="p">}</span>
<span class="k">export</span> <span class="k">default</span> <span class="nx">App</span><span class="p">;</span>
<span class="nx">ReactDom</span><span class="p">.</span><span class="nx">render</span><span class="p">(</span><span class="o">&lt;</span><span class="nx">App</span> <span class="o">/&gt;</span><span class="p">,</span><span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="s1">'element'</span><span class="p">));</span></code></pre></div>
</div>

<div role="tabpanel" class="tab-pane" id="8maqbq35304e8d1c9gihyflcyj827o90-ts" data-original-lang="ts">
<div class="highlight"><pre><code class="prettyprint language-ts" data-lang="ts"><span></span><span class="cm">/* Represents the styles for loader */</span>
<span class="err">#</span><span class="nx">loader</span> <span class="p">{</span>
    <span class="nx">color</span><span class="o">:</span> <span class="err">#</span><span class="mo">00</span><span class="mf">8</span><span class="nx">cff</span><span class="p">;</span>
    <span class="nx">font</span><span class="o">-</span><span class="nx">family</span><span class="o">:</span> <span class="s1">'Helvetica Neue'</span><span class="p">,</span> <span class="s1">'calibiri'</span><span class="p">;</span>
    <span class="nx">font</span><span class="o">-</span><span class="nx">size</span>: <span class="kt">14px</span><span class="p">;</span>
    <span class="nx">height</span>: <span class="kt">40px</span><span class="p">;</span>
    <span class="nx">left</span>: <span class="kt">45</span><span class="o">%</span><span class="p">;</span>
    <span class="nx">position</span>: <span class="kt">absolute</span><span class="p">;</span>
    <span class="nx">top</span>: <span class="kt">45</span><span class="o">%</span><span class="p">;</span>
    <span class="nx">width</span>: <span class="kt">30</span><span class="o">%</span><span class="p">;</span>
<span class="p">}</span>

<span class="p">.</span><span class="nx">wrap</span> <span class="p">{</span>
    <span class="nx">margin</span>: <span class="kt">50px</span> <span class="nx">auto</span><span class="p">;</span>
    <span class="nx">text</span><span class="o">-</span><span class="nx">align</span>: <span class="kt">center</span><span class="p">;</span>
<span class="p">}</span>

<span class="cm">/* To change the radius of the tooltip corners. */</span>
<span class="p">.</span><span class="nx">customtooltip</span><span class="p">.</span><span class="nx">e</span><span class="o">-</span><span class="nx">tooltip</span><span class="o">-</span><span class="nx">wrap</span> <span class="p">{</span>
  <span class="nx">border</span><span class="o">-</span><span class="nx">radius</span>: <span class="kt">3px</span><span class="p">;</span>
<span class="p">}</span>

<span class="cm">/* To change the size of the tooltip content. */</span>
<span class="p">.</span><span class="nx">customtooltip</span><span class="p">.</span><span class="nx">e</span><span class="o">-</span><span class="nx">tooltip</span><span class="o">-</span><span class="nx">wrap</span> <span class="p">.</span><span class="nx">e</span><span class="o">-</span><span class="nx">tip</span><span class="o">-</span><span class="nx">content</span> <span class="p">{</span>
  <span class="nx">font</span><span class="o">-</span><span class="nx">size</span>:<span class="kt">14px</span><span class="p">;</span>
<span class="p">}</span>

<span class="cm">/* To change the border color and width for tooltip. */</span>
<span class="p">.</span><span class="nx">customtooltip</span><span class="p">.</span><span class="nx">e</span><span class="o">-</span><span class="nx">tooltip</span><span class="o">-</span><span class="nx">wrap</span><span class="p">.</span><span class="nx">e</span><span class="o">-</span><span class="nx">popup</span> <span class="p">{</span>
  <span class="nx">border</span>: <span class="kt">2px</span> <span class="nx">solid</span> <span class="err">#</span><span class="mo">000000</span><span class="p">;</span>
<span class="p">}</span>

<span class="cm">/* To change the color for arrow of the tooltip. */</span>
<span class="p">.</span><span class="nx">customtooltip</span><span class="p">.</span><span class="nx">e</span><span class="o">-</span><span class="nx">tooltip</span><span class="o">-</span><span class="nx">wrap</span> <span class="p">.</span><span class="nx">e</span><span class="o">-</span><span class="nx">arrow</span><span class="o">-</span><span class="nx">tip</span><span class="o">-</span><span class="nx">inner</span><span class="p">.</span><span class="nx">e</span><span class="o">-</span><span class="nx">tip</span><span class="o">-</span><span class="nx">bottom</span> <span class="p">{</span>
  <span class="nx">border</span>: <span class="kt">12px</span> <span class="err">#</span><span class="mf">9693</span>
<span class="p">}</span>

<span class="cm">/* To change the top border color for arrow of the tooltip. */</span>
<span class="p">.</span><span class="nx">customtooltip</span><span class="p">.</span><span class="nx">e</span><span class="o">-</span><span class="nx">tooltip</span><span class="o">-</span><span class="nx">wrap</span> <span class="p">.</span><span class="nx">e</span><span class="o">-</span><span class="nx">arrow</span><span class="o">-</span><span class="nx">tip</span><span class="o">-</span><span class="nx">outer</span><span class="p">.</span><span class="nx">e</span><span class="o">-</span><span class="nx">tip</span><span class="o">-</span><span class="nx">bottom</span> <span class="p">{</span>
  <span class="nx">border</span><span class="o">-</span><span class="nx">top</span>: <span class="kt">9.5px</span> <span class="nx">solid</span> <span class="err">#</span><span class="mo">000000</span><span class="p">;</span>
<span class="p">}</span></code></pre></div>
</div>

</div>

</div>

<p><button class="preview-sample-button" id="PreviewSampleButton-q43a5q9g041jvllkj3afg6a1zjvivnip" onclick="LoadPreviewSample('https://ej2.syncfusion.com/react/documentation/code-snippet/rating/tooltip/custom-tooltip-cs1',this.id);">Preview Sample</button><button class="stackblitz-button" id="StackBlitzButton-q43a5q9g041jvllkj3afg6a1zjvivnip" onclick="OpenSampleInStackBlitz('https://ej2.syncfusion.com/react/documentation/code-snippet/rating/tooltip/custom-tooltip-cs1');"><img class="stackblitz-icon" src="https://cdn.syncfusion.com/documentation/images/StackBlitz-icon.png"><span class="stackblitz-text">Open in Stackblitz</span></button></p>
<div id="PreviewSampleHolder-q43a5q9g041jvllkj3afg6a1zjvivnip"></div>

    />);
}
const root = ReactDOM.createRoot(document.getElementById('diagram'));
root.render(<App />);

Disable tooltip at runtime

The tooltip on mouse over can be disabled by setting the diagram’s tooltip property to null. The following code example illustrates how to disable the mouse over tooltip at runtime.

//Initializes the diagram component
  <DiagramComponent id="container" width={'650px'} height={'350px'} 
    //Defines nodes
    nodes={node} connectors={connector}
    //Disables mouse over tooltip at runtime
    tooltip = {null}
    />

Tooltip for Ports

The tooltip feature has been implemented to support Ports, providing the ability to display information or descriptions when the mouse hovers over them.

To display tooltips on mouseover, set the desired tooltip content by utilizing the tooltip property.

Tooltips for Ports can be enabled or disabled using the PortConstraints Tooltip property.

let ports: [{
        offset: {x: 1,y: 0.5},
        tooltip: {content: 'Port Tootip'},
        
        //enable Port Tooltip Constraints
        constraints: PortConstraints.Default | PortConstraints.ToolTip,
        
        //disable Port Tooltip Constraints
        constraints: PortConstraints.Default ~& PortConstraints.ToolTip
    }]

Dynamic modification of tooltip content is supported, allowing you to change the displayed tooltip content during runtime.

{
    //change tooltip content at run time
    diagram.nodes[0].ports[0].tooltip.content = 'New Tooltip Content';
    diagram.databind;
}

Here, the code provided below demonstrates the port tooltip Interaction.

import * as React from "react";
import * as ReactDOM from "react-dom";
import { DiagramComponent,PortConstraints,PortVisibility } from "@syncfusion/ej2-react-diagrams";
// A node is created and stored in nodes array.
let node = [{
        id: "node1",
        width: 100,
        height: 100,
        offsetX: 200,
        offsetY: 200,
        style: {
            strokeColor: '#6BA5D7',
            fill: '#6BA5D7'
        },
        ports:[{
            offset: {
                x: 0.5,
                y: 0
            },
            visibility: PortVisibility.Visible,
            //Defines mouse over tooltip for a node
            tooltip: {
                //Sets the content of the Tooltip
                content: 'Port Tooltip',
            },
            constraints: PortConstraints.Default | PortConstraints.ToolTip
        }]
    }];
//Initializes the Diagram component
function App() {
    return (<DiagramComponent id="container" width={'650px'} height={'350px'} 
    //Defines nodes
    nodes={node}/>);
}
const root = ReactDOM.createRoot(document.getElementById('diagram'));
root.render(<App />);
import * as React from "react";
import * as ReactDOM from "react-dom";
import { DiagramComponent,PortConstraints,PortVisibility,NodeModel } from "@syncfusion/ej2-react-diagrams";
// A node is created and stored in nodes array.
let node:NodeModel[] = [{
        id: "node1",
        width: 100,
        height: 100,
        offsetX: 200,
        offsetY: 200,
        style: {
            strokeColor: '#6BA5D7',
            fill: '#6BA5D7'
        },
        ports:[{
            offset: {
                x: 0.5,
                y: 0
            },
            visibility: PortVisibility.Visible,
            //Defines mouse over tooltip for a node
            tooltip: {
                //Sets the content of the Tooltip
                content: 'Port Tooltip',
            },
            constraints: PortConstraints.Default | PortConstraints.ToolTip
        }]
    }];
//Initializes the Diagram component
function App() {
    return (<DiagramComponent id="container" width={'650px'} height={'350px'} 
    //Defines nodes
    nodes={node}/>);
}
const root = ReactDOM.createRoot(document.getElementById('diagram'));
root.render(<App />);

The following image illustrates how the diagram displays tooltips during an interaction with ports:

Tooltip

Tooltip template content

The tooltip template content allows you to customize the tooltip by using HTML templates. This means you can define the structure and style of the tooltip using HTML, providing greater flexibility and control over its appearance. By leveraging HTML templates, you can include rich content such as formatted text, images, and other HTML elements within the tooltip, enhancing the user experience with more informative and visually appealing tooltips.

The following code example illustrates how to add formatted HTML content to the tooltip.

import * as React from "react";
import * as ReactDOM from "react-dom";
import { DiagramComponent, DiagramConstraints, NodeConstraints } from "@syncfusion/ej2-react-diagrams";
// A node is created and stored in nodes array.
let node = [{
        id: "node1",
        width: 100,
        height: 100,
        annotations: [{
                id: 'label',
                content: 'Rectangle',
                offset: {
                    x: 0.5,
                    y: 0.5
                },
                style: {
                    color: 'white'
                },
            }],
        offsetX: 200,
        offsetY: 200,
        style: {
            strokeColor: '#6BA5D7',
            fill: '#6BA5D7'
        },
        constraints: NodeConstraints.Default | NodeConstraints.Tooltip,
        //Defines mouse over tooltip for a node
        tooltip: {
            //Sets the content of the Tooltip
            content: getContent(),
        }
    }];
function App() {
    return (<DiagramComponent id="container" width={'650px'} height={'350px'} constraints={DiagramConstraints.Default | DiagramConstraints.Tooltip} 
    //Defines nodes
    nodes={node}/>);
}
const root = ReactDOM.createRoot(document.getElementById('diagram'));
root.render(<App />);
function getContent() {
    let tooltipContent = document.createElement('div');
    tooltipContent.innerHTML = '<div style="background-color: #f4f4f4; color: black; border-width:1px;border-style: solid;border-color: #d3d3d3; border-radius: 8px;white-space: nowrap;"> <span style="margin: 10px;"> Tooltip !!! </span> </div>';
    return tooltipContent;
}
import * as React from "react";
import * as ReactDOM from "react-dom";
import {
    Diagram,
    NodeModel,
    DiagramComponent,
    DiagramConstraints,
    NodeConstraints
} from "@syncfusion/ej2-react-diagrams";
import {
    NodeAnimationSettings
} from '@syncfusion/ej2-navigations';
// A node is created and stored in nodes array.
let node: NodeModel[] = [{
                id: "node1",
                width: 100,
                height: 100,
                annotations: [{
                    id: 'label',
                    content: 'Rectangle',
                    offset: {
                        x: 0.5,
                        y: 0.5
                    },
                    style: {
                        color: 'white'
                    },
                }],
                offsetX: 200,
                offsetY: 200,
                style: {
                    strokeColor: '#6BA5D7',
                    fill: '#6BA5D7'
                },
                constraints: NodeConstraints.Default | NodeConstraints.Tooltip,
                //Defines mouse over tooltip for a node
                tooltip: {
                    //Sets the content of the Tooltip
                    content: getContent(),
                }
            }];

function App() {
  return (
    <DiagramComponent
      id="container"
      width={'650px'}
      height={'350px'}
      constraints={DiagramConstraints.Default | DiagramConstraints.Tooltip}
      //Defines nodes
      nodes={node}
    />
  );
}
const root = ReactDOM.createRoot(document.getElementById('diagram'));
root.render(<App />);

function getContent(): HTMLElement {
    let tooltipContent: HTMLElement = document.createElement('div');
    tooltipContent.innerHTML = '<div style="background-color: #f4f4f4; color: black; border-width:1px;border-style: solid;border-color: #d3d3d3; border-radius: 8px;white-space: nowrap;"> <span style="margin: 10px;"> Tooltip !!! </span> </div>';
    return tooltipContent;
}

Tooltip alignments

Tooltip relative to object

The diagram supports displaying a tooltip around the node or connector that is hovered over by the mouse. The tooltip’s alignment can be adjusted using the position property. The relativeMode property specifies whether the tooltip should be displayed around the object or at the mouse position.

The following code example illustrates how to position the tooltip around object.

import * as React from "react";
import * as ReactDOM from "react-dom";
import { DiagramComponent, DiagramConstraints, NodeConstraints } from "@syncfusion/ej2-react-diagrams";
// A node is created and stored in nodes array.
let node = [{
        id: "node1",
        width: 100,
        height: 100,
        annotations: [{
                id: 'label',
                content: 'Rectangle',
                offset: {
                    x: 0.5,
                    y: 0.5
                },
                style: {
                    color: 'white'
                }
            }],
        offsetX: 200,
        offsetY: 200,
        style: {
            strokeColor: '#6BA5D7',
            fill: '#6BA5D7'
        },
        constraints: NodeConstraints.Default | NodeConstraints.Tooltip,
        //Defines mouse over tooltip for a node
        tooltip: {
            content: 'Node1',
            //Sets the alignment properties
            position: 'BottomRight',
            //Sets to show tooltip around the element
            relativeMode: 'Object',
        },
    }];
//Initializes the Diagram component
function App() {
    return (<DiagramComponent id="container" width={'650px'} height={'350px'} constraints={DiagramConstraints.Default | DiagramConstraints.Tooltip} 
    //Defines nodes
    nodes={node}/>);
}
const root = ReactDOM.createRoot(document.getElementById('diagram'));
root.render(<App />);
import * as React from "react";
import * as ReactDOM from "react-dom";
import {
    Diagram,
    NodeModel,
    DiagramComponent,
    DiagramConstraints,
    NodeConstraints
} from "@syncfusion/ej2-react-diagrams";
import {
    NodeAnimationSettings
} from '@syncfusion/ej2-navigations';
// A node is created and stored in nodes array.
let node: NodeModel[] = [{
                id: "node1",
                width: 100,
                height: 100,
                annotations: [{
                    id: 'label',
                    content: 'Rectangle',
                    offset: {
                        x: 0.5,
                        y: 0.5
                    },
                    style: {
                        color: 'white'
                    }
                }],
                offsetX: 200,
                offsetY: 200,
                style: {
                    strokeColor: '#6BA5D7',
                    fill: '#6BA5D7'
                },
                constraints: NodeConstraints.Default | NodeConstraints.Tooltip,
                //Defines mouse over tooltip for a node
                tooltip: {
                    content: 'Node1',
                    //Sets the alignment properties
                    position: 'BottomRight',
                    //Sets to show tooltip around the element
                    relativeMode: 'Object',
                },
            }];
//Initializes the Diagram component
function App() {
  return (
    <DiagramComponent
      id="container"
      width={'650px'}
      height={'350px'}
      constraints={DiagramConstraints.Default | DiagramConstraints.Tooltip}
      //Defines nodes
      nodes={node}
    />
  );
}
const root = ReactDOM.createRoot(document.getElementById('diagram'));
root.render(<App />);

Tooltip relative to mouse position

To display the tooltip at the mouse position, set the mouse option in the relativeMode property of the tooltip.

The following code example illustrates how to show tooltip at mouse position.

import * as React from "react";
import * as ReactDOM from "react-dom";
import { DiagramComponent, DiagramConstraints, NodeConstraints } from "@syncfusion/ej2-react-diagrams";
let node = [{
        id: "node1",
        width: 100,
        height: 100,
        annotations: [{
                id: 'label',
                content: 'Rectangle',
                offset: {
                    x: 0.5,
                    y: 0.5
                },
                style: {
                    color: 'white'
                }
            }],
        offsetX: 200,
        offsetY: 200,
        style: {
            strokeColor: '#6BA5D7',
            fill: '#6BA5D7'
        },
        constraints: NodeConstraints.Default | NodeConstraints.Tooltip,
        //Defines mouse over tooltip for a node
        tooltip: {
            content: 'Node1',
            //Sets to show tooltip at mouse position
            relativeMode: 'Mouse',
        },
    }];
//Initializes the Diagram component
function App() {
    return (<DiagramComponent id="container" width={'650px'} height={'350px'} constraints={DiagramConstraints.Default | DiagramConstraints.Tooltip} 
    //Defines nodes
    nodes={node}/>);
}
const root = ReactDOM.createRoot(document.getElementById('diagram'));
root.render(<App />);
import * as React from "react";
import * as ReactDOM from "react-dom";
import {
    Diagram,
    NodeModel,
    DiagramComponent,
    DiagramConstraints,
    NodeConstraints
} from "@syncfusion/ej2-react-diagrams";
import {
    NodeAnimationSettings
} from '@syncfusion/ej2-navigations';
let node: NodeModel[] = [{
                id: "node1",
                width: 100,
                height: 100,
                annotations: [{
                    id: 'label',
                    content: 'Rectangle',
                    offset: {
                        x: 0.5,
                        y: 0.5
                    },
                    style: {
                        color: 'white'
                    }
                }],
                offsetX: 200,
                offsetY: 200,
                style: {
                    strokeColor: '#6BA5D7',
                    fill: '#6BA5D7'
                },
                constraints: NodeConstraints.Default | NodeConstraints.Tooltip,
                //Defines mouse over tooltip for a node
                tooltip: {
                    content: 'Node1',
                    //Sets to show tooltip at mouse position
                    relativeMode: 'Mouse',
                },
            }];
//Initializes the Diagram component
function App() {
  return (
    <DiagramComponent
      id="container"
      width={'650px'}
      height={'350px'}
      constraints={DiagramConstraints.Default | DiagramConstraints.Tooltip}
      //Defines nodes
      nodes={node}
    />
  );
}
const root = ReactDOM.createRoot(document.getElementById('diagram'));
root.render(<App />);

Tooltip animation

To animate the tooltip, you can use a range of animation effects controlled by the animation property. This property allows you to customize the delay, duration, and various other effects according to your preferences.

Refer the following sample where we used zoomIn animation for tooltip open and zoomOut animation for tooltip close with delay and duration.

import * as React from "react";
import * as ReactDOM from "react-dom";
import { DiagramComponent, DiagramConstraints, NodeConstraints } from "@syncfusion/ej2-react-diagrams";
let node = [{
        id: "node1",
        width: 100,
        height: 100,
        annotations: [{
                id: 'label',
                content: 'Rectangle',
                offset: {
                    x: 0.5,
                    y: 0.5
                },
                style: {
                    color: 'white'
                },
            }],
        offsetX: 200,
        offsetY: 200,
        style: {
            strokeColor: '#6BA5D7',
            fill: '#6BA5D7'
        },
        constraints: NodeConstraints.Default | NodeConstraints.Tooltip,
        //Defines mouse over tooltip for a node
        tooltip: {
            content: 'Node1',
            position: 'BottomCenter',
            relativeMode: 'Object',
            animation: {
                //Animation settings to be applied on the Tooltip, while it is being shown over the target.
                open: {
                    //Animation effect on the Tooltip is applied during open and close actions.
                    effect: 'ZoomIn',
                    //Duration of the animation that is completed per animation cycle.
                    duration: 1000,
                    //Indicating the waiting time before animation begins.
                    delay: 0
                },
                //Animation settings to be applied on the Tooltip, when it is closed.
                close: {
                    effect: 'ZoomOut',
                    duration: 500,
                    delay: 0
                },
            },
        },
    }];
//Initializes the Diagram component
function App() {
    return (<DiagramComponent id="container" width={'650px'} height={'350px'} constraints={DiagramConstraints.Default | DiagramConstraints.Tooltip} 
    //Defines nodes
    nodes={node}/>);
}
const root = ReactDOM.createRoot(document.getElementById('diagram'));
root.render(<App />);
import * as React from "react";
import * as ReactDOM from "react-dom";
import {
        Diagram,
        DiagramComponent,
        NodeModel,
        DiagramConstraints,
        NodeConstraints
    } from "@syncfusion/ej2-react-diagrams";
import {
        NodeAnimationSettings
    } from '@syncfusion/ej2-navigations';
let node: NodeModel[] = [{
                    id: "node1",
                    width: 100,
                    height: 100,
                    annotations: [{
                        id: 'label',
                        content: 'Rectangle',
                        offset: {
                            x: 0.5,
                            y: 0.5
                        },
                        style: {
                            color: 'white'
                        },
                    }],
                    offsetX: 200,
                    offsetY: 200,
                    style: {
                        strokeColor: '#6BA5D7',
                        fill: '#6BA5D7'
                    },
                    constraints: NodeConstraints.Default | NodeConstraints.Tooltip,
                    //Defines mouse over tooltip for a node
                    tooltip: {
                        content: 'Node1',
                        position: 'BottomCenter',
                        relativeMode: 'Object',
                        animation: {
                            //Animation settings to be applied on the Tooltip, while it is being shown over the target.
                            open: {
                                //Animation effect on the Tooltip is applied during open and close actions.
                                effect: 'ZoomIn',
                                //Duration of the animation that is completed per animation cycle.
                                duration: 1000,
                                //Indicating the waiting time before animation begins.
                                delay: 0
                            },
                            //Animation settings to be applied on the Tooltip, when it is closed.
                            close: {
                                effect: 'ZoomOut',
                                duration: 500,
                                delay: 0
                            },
                        },
                    },
                }];

//Initializes the Diagram component
function App() {
  return (
    <DiagramComponent
      id="container"
      width={'650px'}
      height={'350px'}
      constraints={DiagramConstraints.Default | DiagramConstraints.Tooltip}
      //Defines nodes
      nodes={node}
    />
  );
}
const root = ReactDOM.createRoot(document.getElementById('diagram'));
root.render(<App />);

Sticky tooltip

A sticky tooltip will remain visible even after you move the mouse away from the node or connector. You can activate this feature by setting the isSticky property of the tooltip.

The following example shows how to render sticky tooltip.

import * as React from "react";
import * as ReactDOM from "react-dom";
import { DiagramComponent, DiagramConstraints, NodeConstraints } from "@syncfusion/ej2-react-diagrams";
let node = [{
        id: "node1",
        width: 100,
        height: 100,
        annotations: [{
                id: 'label',
                content: 'Rectangle',
                offset: {
                    x: 0.5,
                    y: 0.5
                },
                style: {
                    color: 'white'
                },
            }],
        offsetX: 200,
        offsetY: 200,
        style: {
            strokeColor: '#6BA5D7',
            fill: '#6BA5D7'
        },
        constraints: NodeConstraints.Default | NodeConstraints.Tooltip,
        //Defines mouse over tooltip for a node
        tooltip: {
            content: 'Node1',
            position: 'BottomCenter',
            relativeMode: 'Object',
             //Activate sticky mode for tooltip
              isSticky: true,
        },
    }];
//Initializes the Diagram component
function App() {
    return (<DiagramComponent id="container" width={'650px'} height={'350px'} constraints={DiagramConstraints.Default | DiagramConstraints.Tooltip} 
    //Defines nodes
    nodes={node}/>);
}
const root = ReactDOM.createRoot(document.getElementById('diagram'));
root.render(<App />);
import * as React from "react";
import * as ReactDOM from "react-dom";
import { DiagramComponent, DiagramConstraints, NodeConstraints,NodeModel } from "@syncfusion/ej2-react-diagrams";
let node: NodeModel[] = [{
        id: "node1",
        width: 100,
        height: 100,
        annotations: [{
                id: 'label',
                content: 'Rectangle',
                offset: {
                    x: 0.5,
                    y: 0.5
                },
                style: {
                    color: 'white'
                },
            }],
        offsetX: 200,
        offsetY: 200,
        style: {
            strokeColor: '#6BA5D7',
            fill: '#6BA5D7'
        },
        constraints: NodeConstraints.Default | NodeConstraints.Tooltip,
        //Defines mouse over tooltip for a node
        tooltip: {
            content: 'Node1',
            position: 'BottomCenter',
            relativeMode: 'Object',
             //Activate sticky mode for tooltip
              isSticky: true,
        },
    }];
//Initializes the Diagram component
function App() {
    return (<DiagramComponent id="container" width={'650px'} height={'350px'} constraints={DiagramConstraints.Default | DiagramConstraints.Tooltip} 
    //Defines nodes
    nodes={node}/>);
}
const root = ReactDOM.createRoot(document.getElementById('diagram'));
root.render(<App />);

Hide tooltip pointer

The showTipPointer property allows to control the visibility of tooltip pointer. By default, the showTipPointer is set as true.

import * as React from "react";
import * as ReactDOM from "react-dom";
import { DiagramComponent, DiagramConstraints, NodeConstraints } from "@syncfusion/ej2-react-diagrams";
let node = [{
        id: "node1",
        width: 100,
        height: 100,
        annotations: [{
                id: 'label',
                content: 'Rectangle',
                offset: {
                    x: 0.5,
                    y: 0.5
                },
                style: {
                    color: 'white'
                },
            }],
        offsetX: 200,
        offsetY: 200,
        style: {
            strokeColor: '#6BA5D7',
            fill: '#6BA5D7'
        },
        constraints: NodeConstraints.Default | NodeConstraints.Tooltip,
        //Defines mouse over tooltip for a node
        tooltip: {
            content: 'Node1',
            position: 'BottomCenter',
            relativeMode: 'Object',
             //Hide tip pointer
             showTipPointer: false,
        },
    }];
//Initializes the Diagram component
function App() {
    return (<DiagramComponent id="container" width={'650px'} height={'350px'} constraints={DiagramConstraints.Default | DiagramConstraints.Tooltip} 
    //Defines nodes
    nodes={node}/>);
}
const root = ReactDOM.createRoot(document.getElementById('diagram'));
root.render(<App />);
import * as React from "react";
import * as ReactDOM from "react-dom";
import { DiagramComponent, DiagramConstraints, NodeConstraints,NodeModel } from "@syncfusion/ej2-react-diagrams";
let node: NodeModel[] = [{
        id: "node1",
        width: 100,
        height: 100,
        annotations: [{
                id: 'label',
                content: 'Rectangle',
                offset: {
                    x: 0.5,
                    y: 0.5
                },
                style: {
                    color: 'white'
                },
            }],
        offsetX: 200,
        offsetY: 200,
        style: {
            strokeColor: '#6BA5D7',
            fill: '#6BA5D7'
        },
        constraints: NodeConstraints.Default | NodeConstraints.Tooltip,
        //Defines mouse over tooltip for a node
        tooltip: {
            content: 'Node1',
            position: 'BottomCenter',
            relativeMode: 'Object',
            //Hide tip pointer
            showTipPointer: false,
        },
    }];
//Initializes the Diagram component
function App() {
    return (<DiagramComponent id="container" width={'650px'} height={'350px'} constraints={DiagramConstraints.Default | DiagramConstraints.Tooltip} 
    //Defines nodes
    nodes={node}/>);
}
const root = ReactDOM.createRoot(document.getElementById('diagram'));
root.render(<App />);

Tooltip size

By default, the size of the tooltip is calculated based on its content. If you want to customize the size, you can use the width and height properties of the tooltip.

The following code example shows how to set the size for the tooltip:

import * as React from "react";
import * as ReactDOM from "react-dom";
import { DiagramComponent, DiagramConstraints, NodeConstraints } from "@syncfusion/ej2-react-diagrams";
let node = [{
        id: "node1",
        width: 100,
        height: 100,
        annotations: [{
                id: 'label',
                content: 'Rectangle',
                offset: {
                    x: 0.5,
                    y: 0.5
                },
                style: {
                    color: 'white'
                },
            }],
        offsetX: 200,
        offsetY: 200,
        style: {
            strokeColor: '#6BA5D7',
            fill: '#6BA5D7'
        },
        constraints: NodeConstraints.Default | NodeConstraints.Tooltip,
        //Defines mouse over tooltip for a node
        tooltip: {
            content:
            'Syncfusion diagram nodes, connectors look and feel can also be customized any way you want. The JavaScript Diagram control provides a rich set of properties through which you can customize connector color, thickness, dash and dot appearance, corners, and even decorators',
          position: 'BottomCenter',
          relativeMode: 'Object',
          //Set size for tooltip
          width: 300,
          height: 100,
        },
    }];
//Initializes the Diagram component
function App() {
    return (<DiagramComponent id="container" width={'650px'} height={'350px'} constraints={DiagramConstraints.Default | DiagramConstraints.Tooltip} 
    //Defines nodes
    nodes={node}/>);
}
const root = ReactDOM.createRoot(document.getElementById('diagram'));
root.render(<App />);
import * as React from "react";
import * as ReactDOM from "react-dom";
import { DiagramComponent, DiagramConstraints, NodeConstraints,NodeModel } from "@syncfusion/ej2-react-diagrams";
let node: NodeModel[] = [{
        id: "node1",
        width: 100,
        height: 100,
        annotations: [{
                id: 'label',
                content: 'Rectangle',
                offset: {
                    x: 0.5,
                    y: 0.5
                },
                style: {
                    color: 'white'
                },
            }],
        offsetX: 200,
        offsetY: 200,
        style: {
            strokeColor: '#6BA5D7',
            fill: '#6BA5D7'
        },
        constraints: NodeConstraints.Default | NodeConstraints.Tooltip,
        //Defines mouse over tooltip for a node
        tooltip: {
            content:
            'Syncfusion diagram nodes, connectors look and feel can also be customized any way you want. The JavaScript Diagram control provides a rich set of properties through which you can customize connector color, thickness, dash and dot appearance, corners, and even decorators',
          position: 'BottomCenter',
          relativeMode: 'Object',
          //Set size for tooltip
          width: 300,
          height: 100,
        },
    }];
//Initializes the Diagram component
function App() {
    return (<DiagramComponent id="container" width={'650px'} height={'350px'} constraints={DiagramConstraints.Default | DiagramConstraints.Tooltip} 
    //Defines nodes
    nodes={node}/>);
}
const root = ReactDOM.createRoot(document.getElementById('diagram'));
root.render(<App />);

Show/Hide tooltip at runtime

You can show or hide the tooltip dynamically using a button click with the showTooltip and hideTooltip methods of the diagram. This allows you to control the tooltip visibility programmatically rather than relying on user hover actions. In some cases, you may want to display the tooltip without requiring the user to hover over the object.

The following example demonstrates how to show or hide the tooltip at runtime:

import * as React from "react";
import * as ReactDOM from "react-dom";
import { DiagramComponent, DiagramConstraints, NodeConstraints } from "@syncfusion/ej2-react-diagrams";
let diagramInstance;
let node = [{
        id: "node1",
        width: 100,
        height: 100,
        annotations: [{
                id: 'label',
                content: 'Rectangle',
                offset: {
                    x: 0.5,
                    y: 0.5
                },
                style: {
                    color: 'white'
                },
            }],
        offsetX: 200,
        offsetY: 200,
        style: {
            strokeColor: '#6BA5D7',
            fill: '#6BA5D7'
        },
        constraints: NodeConstraints.Default | NodeConstraints.Tooltip,
        //Defines mouse over tooltip for a node
        tooltip: {
            content: 'Node1',
            position: 'BottomCenter',
            relativeMode: 'Object',
           //To show tooltip on button click
          openOn: 'Custom',
        },
    }];
//Initializes the Diagram component
function App() {
    const showTooltip = () => {
    /**
   * parameter -  The object for which the tooltip will be shown.
   */
     diagramInstance.showTooltip(diagramInstance.nodes[0]);  
    }
    const hideTooltip = () => {
    /**
   * parameter - The object for which the tooltip should be hidden.
   */
     diagramInstance.hideTooltip(diagramInstance.nodes[0]);
    }
    return (
    <div>
      <button  onClick={showTooltip}>showTooltip</button>
      <button  onClick={hideTooltip}>hideTooltip</button>
    <DiagramComponent id="container" width={'650px'} 
    ref={(diagram) => (diagramInstance = diagram)}
    height={'350px'} constraints={DiagramConstraints.Default | DiagramConstraints.Tooltip} 
    //Defines nodes
    nodes={node}/>
    </div>
    );
}
const root = ReactDOM.createRoot(document.getElementById('diagram'));
root.render(<App />);
import * as React from "react";
import * as ReactDOM from "react-dom";
import { DiagramComponent, DiagramConstraints, NodeConstraints,NodeModel } from "@syncfusion/ej2-react-diagrams";
let diagramInstance:DiagramComponent;
let node:NodeModel[] = [{
        id: "node1",
        width: 100,
        height: 100,
        annotations: [{
                id: 'label',
                content: 'Rectangle',
                offset: {
                    x: 0.5,
                    y: 0.5
                },
                style: {
                    color: 'white'
                },
            }],
        offsetX: 200,
        offsetY: 200,
        style: {
            strokeColor: '#6BA5D7',
            fill: '#6BA5D7'
        },
        constraints: NodeConstraints.Default | NodeConstraints.Tooltip,
        //Defines mouse over tooltip for a node
        tooltip: {
            content: 'Node1',
            position: 'BottomCenter',
            relativeMode: 'Object',
           //To show tooltip on button click
          openOn: 'Custom',
        },
    }];
//Initializes the Diagram component
function App() {
    const showTooltip = () => {
    /**
   * parameter -  The object for which the tooltip will be shown.
   */
     diagramInstance.showTooltip(diagramInstance.nodes[0]);  
    }
    const hideTooltip = () => {
    /**
   * parameter - The object for which the tooltip should be hidden.
   */
     diagramInstance.hideTooltip(diagramInstance.nodes[0]);
    }
    return (
    <div>
      <button  onClick={showTooltip}>showTooltip</button>
      <button  onClick={hideTooltip}>hideTooltip</button>
    <DiagramComponent id="container" width={'650px'} 
    ref={(diagram) => (diagramInstance = diagram)}
    height={'350px'} constraints={DiagramConstraints.Default | DiagramConstraints.Tooltip} 
    //Defines nodes
    nodes={node}/>
    </div>
    );
}
const root = ReactDOM.createRoot(document.getElementById('diagram'));
root.render(<App />);

Tooltip for Annotation

Tooltips can be added to annotations to display additional information on mouseover.
To display tooltips on mouseover, set the desired tooltip text to the tooltip property of the annotation.
Tooltips for Annotations can be enabled or disabled by setting the AnnotationConstraints property as Tooltip.

import * as React from "react";
import * as ReactDOM from "react-dom";
import { DiagramComponent, DiagramConstraints,AnnotationConstraints, NodeConstraints } from "@syncfusion/ej2-react-diagrams";
// A node is created and stored in nodes array.
let node =  [ {
    id: 'node1',
    offsetX: 150,
    offsetY: 150,
    width: 100,
    height: 100,
    style: {
        fill: '#6BA5D7',
        strokeColor: 'white'
    },
    annotations: [{
            id: 'label1',
            content: 'Rectangle',
            tooltip: {
                content: 'Rectangle',
                position: 'TopRight',
                relativeMode: 'Object',
            },
            constraints: AnnotationConstraints.Tooltip,
        }],
}];
//Initializes the Diagram component
function App() {
    return (<DiagramComponent id="container" width={'650px'} height={'350px'} 
    //Defines nodes
    nodes={node}/>);
}
const root = ReactDOM.createRoot(document.getElementById('diagram'));
root.render(<App />);
import * as React from "react";
import * as ReactDOM from "react-dom";
import {
    Diagram,
    NodeModel,
    DiagramComponent,
    DiagramConstraints,
    AnnotationConstraints,
    NodeConstraints
} from "@syncfusion/ej2-react-diagrams";
import {
    NodeAnimationSettings
} from '@syncfusion/ej2-navigations';
// A node is created and stored in nodes array.
let node: NodeModel[] = [ {
    id: 'node1',
    offsetX: 150,
    offsetY: 150,
    width: 100,
    height: 100,
    style: {
        fill: '#6BA5D7',
        strokeColor: 'white'
    },
    annotations: [{
            id: 'label1',
            content: 'Rectangle',
            tooltip: {
                content: 'Rectangle',
                position: 'TopRight',
                relativeMode: 'Object',
            },
            constraints: AnnotationConstraints.Tooltip,
        }],
}];
//Initializes the Diagram component
function App() {
  return (
    <DiagramComponent
      id="container"
      width={'650px'}
      height={'350px'}
      //Defines nodes
      nodes={node}
    />
  );
}
const root = ReactDOM.createRoot(document.getElementById('diagram'));
root.render(<App />);