Replies: 7 comments 1 reply
-
Just submitted a PR #12128 for adding this |
Beta Was this translation helpful? Give feedback.
-
I've had similar thoughts, but I'm not sure if it's a good idea for a core TW utility to be setting different properties in different environments. That said, if this were to be implemented, something like this might be a little cleaner: @supports not (overflow-wrap: anywhere) {
.break-anywhere {
word-break: break-word;
}
}
@supports (overflow-wrap: anywhere) {
.break-anywhere {
overflow-wrap: anywhere;
}
} |
Beta Was this translation helpful? Give feedback.
-
Sorry but with
Use case is a heading or paragraph text instance of a very long chain of characters such as:
|
Beta Was this translation helpful? Give feedback.
-
I'm with you @mdrideout. In the meantime, I'll temporarily create a CSS class for this utility in my own root css file or in my tailwind config file. |
Beta Was this translation helpful? Give feedback.
-
Once there, [overflow-wrap:anywhere] or something like that might be fine! |
Beta Was this translation helpful? Give feedback.
-
anytime it get integrated in tailwind? |
Beta Was this translation helpful? Give feedback.
-
Any update on this? |
Beta Was this translation helpful? Give feedback.
-
Clear and concise description of the problem
Before we start, according to MDN's
word-break
introduction:word-break: break-word
is deprecatedword-break: break-word
=word-break: normal
+overflow-wrap: anywhere
The problem is Tailwind CSS only provides the
break-words
class (corresponding to CSSoverflow-wrap: break-word;
) and does not supportword-break: break-word
/overflow-wrap: anywhere
.The
overflow-wrap
documentation mentions that thebreak-word
andanywhere
values are almost identical, but there are still some differences.anywhere
Soft wrap opportunities introduced by the word break are considered when calculating min-content intrinsic sizes.
break-word
... soft wrap opportunities introduced by the word break are
NOT
considered when calculating min-content intrinsic sizes.Research
Although I have not delved into the underlying principles in practice, I have done a code test to demonstrate the differences between different values in use:
Source code: Tailwind Play
As you can see in the example above, neither
break-words
norbreak-all
can fully serve as replacements.min-w-0
is hacky and not perfectSeveral solutions have been proposed for content word wrapping, one of which includes the combination of
min-w-0
withbreak-words
(related issues). While this method is recognized, it presents certain limitations. Specifically, it necessitates its application directly to the content element. This is in contrast to theoverflow-wrap: anywhere
property, which can be applied to the parent element, subsequently affecting all child content for word breaking.Source code: Tailwind Play
Suggested solution
Current browser support situation:
word-break: break-word
is deprecated, it can still be used in the latest version of Chromeoverflow-wrap: anywhere;
is only at 91.87%, with support in iOS 15.4 and aboveGiven the above situation, I propose the following solution and fallback methods and hope for feedback from everyone.
Naming reason (
break-anywhere
):break-
as a prefix to easily categorize it with other similar word break classesanywhere
as a suffix because I do not want to confuse it withbreak-words
, andoverflow-wrap: anywhere;
is the replacement forword-break: break-word;
.Alternative
For those who looking for Tailwind CSS class utilities.
Related
Issues: #835, #10004, #11255, #10481
My original research: unocss/unocss#2614
Beta Was this translation helpful? Give feedback.
All reactions