I am using react-tooltip with an information icon. I have added a custom class to my tooltip element. But I am unable to style it in CSS, even though I am using !important
. I went through How to align the text to the left. in react-tooltip? but that didn't help me. The border-radius, padding, font-size etc. doesn't change. Here's my code:-
.tooltip {
border-radius: 8px !important;
padding: 8px !important;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif !important;
font-size: 16px !important;
font-weight: normal !important;
filter: drop-shadow(rgba(0, 0, 0, 0.3) 0 2px 10px) !important;
}
<span className='iconInfo' data-tip data-for='myTip'>ⓘ</span> <ReactTooltip id='myTip' className='tooltip' place='right' effect='solid' type='light' border='true'>My Tooltip</ReactTooltip>
Edit 1:
So, I have changed the <text>
to <span>
. And, I don't have any class for the <span>
now. I have a class name for the tooltip. <span data-tip data-for='invoiceTip'>ⓘ</span> <ReactTooltip id='invoiceTip' className='tooltip' place='right' effect='solid' type='light' border={true}>{t('invoice_tooltip')}</ReactTooltip>
. But, I still can't get it to work. Here's the edited CSS:-
.tooltip .place-right {
border-radius: 8px !important;
padding: 8px !important;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
font-size: 16px !important;
font-weight: normal;
/* filter: drop-shadow(rgba(0, 0, 0, 0.3) 0 2px 10px); */
}
I have tried .tooltip
, .tooltip .place-right
, .tooltip.__react_component_tooltip
, with and without !important
. None of them have worked.
Edit 2:
I got where I went wrong. I was using a bunch of info icons and each of them had their own ReactTooltip element, while in the CSS I was styling only one common element. The best way is to keep the ReactTooltip element at the end, maybe in the same hierarchy as all the elements using it. Thanks to https://egghead.io/lessons/react-easily-add-tooltips-to-a-react-app-with-react-tooltip-library for pointing me in the right direction.