I am trying to display a tooltip on hover using the data-tip attribute, but I am facing limitations with it only accepting strings. As a workaround, I have adopted the following approach:
var title = "Hello World";
var online: "Last Online 2 mins ago".
<div>
<span data-tip={title +" \n " +online} data-tip-always>{title}</span>
</div>
However, I am now encountering an issue on how to style {title}
as bold and set {online}
font-size smaller than {title}
.
Here is my updated code:
const titles = `<span class="title">Hello</span>`;
const online = `<span class="online">You are online</span>` ;
<span data-tip={`${titles}\n${online}`} data-html="true" data-tip-always>{title}</span>
As a result, I am currently seeing this formatting:
https://i.sstatic.net/tAYXU.pngInitially, I attempted to implement this in JSX to apply colors and fonts, however, I struggled to find a way to incorporate JSX/HTML within a data-tip
. Is there a method to apply CSS styles directly to strings?
Thank you.