0

I'm trying to build a multiline tooltip using [this example], I'm using it as a refernce because it involves functional components. It works just fine, when its a short line of text, but doesn't go on a new line, which is something that I need.

I tried adding < /br > inside of the content, changing the content to jsx format and adding code below to the css file:

  width: 200px;
  word-wrap: break-word;

All it managed to do was decrease the tooltip backgronud width to 200px.

How do I change code in the example to go on a new line if content size width is going above the predetermined width?

1 Answer 1

1

How do I change code in the example to go on a new line if content size width is going above the predetermined width?

Besides setting the width to the e.g. 200px, you should also remove the white-space: nowrap; property because that is simply disallowing the text to break, even if it does overflow the container.

Codesandbox: https://codesandbox.io/s/how-to-make-an-extremely-reusable-tooltip-component-with-react-and-nothing-else-forked-v09e4y

More info about white-space property: https://developer.mozilla.org/en-US/docs/Web/CSS/white-space

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks alot kind user! Completely overlooked that property

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.