1

I am using react-tooltip, but I am unable to use some css on html tool tip.

Here, is my code:

export default function App() {
  useEffect(() => {
    ReactTooltip.rebuild();
  });
  return (
    <div className="App">
      <table>
        <tbody>
          <tr>
            <td
              data-tip='<div className="unit-tooltip">
          <div className="unit-title">Unit:5401</div>
          <div className="unit-content">
            <ul>
              <li>Floor level 05 = 75</li>
              <li>Floor level 05 = 75</li>
            </ul>
          </div>
        </div>'
              data-html={true}
            >
              hover me
            </td>
            <td
              data-tip='<div className="unit-tooltip">
          <div className="unit-title">Unit:5402</div>
          <div className="unit-content">
            <ul>
              <li>Floor level 04 = 80</li>
              <li>Floor level 04 = 80</li>
            </ul>
          </div>
        </div>'
              data-html={true}
            >
              hover me
            </td>
          </tr>
        </tbody>
      </table>

      <ReactTooltip place="bottom" effect="solid" type="light" />
    </div>
  );
}

All these td, would be dynamically listed.

I have used background color for class unit-title, but its not working. Here is the sandox link

1 Answer 1

1

In your td, it should be class, not className, because react-tooltip render a raw html, not jsx

<td
    data-tip='<div class="unit-tooltip">
          <div class="unit-title">Unit:5401</div>
          <div class="unit-content">
            <ul>
              <li>Floor level 05 = 75</li>
              <li>Floor level 05 = 75</li>
            </ul>
          </div>
        </div>'
    data-html={true}
>
    hover me
</td>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.