Tooltip Text Wrapping #3653
-
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
Disclaimer: This is a very experimental bot using OpenAI's GPT-4. The answers may not be correct, a human will review the answer and update it if necessary. Sorry, but according to the Paste documentation, tooltips can only contain text content and should only contain information that provides additional context or guidance for the user. They are not designed to handle long, unbroken strings of text that do not fit within their container. For long trait names, you might want to consider using the Truncate component. This component is designed to handle text or links that exceed the size of their container. It will cut off the text based on the parent container's width and append an ellipsis ( Here's an example of how you might use the Truncate component: import {Truncate} from '@twilio-paste/core/truncate';
<Truncate>VeryLongTraitNameThatExceedsTheSizeOfItsContainer</Truncate> This will display the trait name up to the width of its container, followed by an ellipsis. When the user hovers over the truncated text, the full trait name will be displayed. If you need to display the full trait name in a tooltip, you might need to implement a custom solution, as the Tooltip component in Paste is not designed to handle this use case. I also did a search, and I managed to find these other Discussions that might be similar or related to your question. Give them a read to see if they answer your question. If they do, head back here and update this discussion and mark it as answered, pointing others to the related discussion:
|
Beta Was this translation helpful? Give feedback.
-
we need a way to show long trait names regardless of what the documentation says. what is the general design guidance to do something like this? |
Beta Was this translation helpful? Give feedback.
Hi
In this case, the suggestion made by PasteBot is probably the right path. It just misses one small detail from the Truncate component, which is the title attribute.
Tooltips can only be place on actionable, focusable elements in any UI. That is WCAG requirement for accessibility. They can't be placed on text, so they can't be used for showing the long strings, unless that long string is in a link, or a button. I'm not sure if that is the case here.
By using the Truncate component with the title attribute, you do get the full string on hover via the browser native API. It's not perfect, but it's not inaccessible.
Hopefully that solves for the case, if you're not using focusable elements.
…