I am Working on a Prismic React Project, In which I need a functionality to show tooltip from rich text editor which is expected to show from the nested tags in Rich Text editor. A little bit help will be of lot of beneficial to us.
This is the functionality I want, but this is not specific how many times and where we need to show this thing in the whole project:
You can use a custom HTMLSerializer and a library for tooltips. Here’s an example where I used the
react-tooltip
(npm link)The serializer will detect the text and wrap it in a paragraph tag; then, it will use the label as the
data-for
andid
attributes and the tooltip content itself in the<ReactTooltip />
component.After that, I passed it to my Rich Text field.
Then, you'd just need to style it as you like. Here's a preview of how the component looks like: