Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add break-anywhere utility #12128

Open
wants to merge 3 commits into
base: next
Choose a base branch
from

Conversation

serkodev
Copy link

@serkodev serkodev commented Oct 3, 2023

Related discussion #12127

.break-anywhere {
  overflow-wrap: anywhere;
}

Updated 2024-11-30

The new changes remove the original @supports because I agree that developers should decide for themselves whether to maintain backward compatibility. Also updated in line with the new changes in the next branch.

@serkodev serkodev changed the title Add break-anywhere utility (#12127) Add break-anywhere utility Oct 3, 2023
@brandonmcconnell
Copy link
Contributor

@serkodev This looks great. Are there any side effects you know of for browsers that do not yet support either of these, or would this work purely, as a progressive enhancement?

@serkodev
Copy link
Author

@brandonmcconnell For browsers that do not support overflow-wrap: anywhere, it's likely that they will support the older property word-break: break-word given its longevity in the web standards.

Moreover, the @supports (not) query boasts a substantial 97.77% browser coverage. This suggests that the approach should function effectively in the vast majority of browsing environments. So it should serve as a progressive enhancement, ensuring a seamless experience for users across different browsers.

@jonathanlal
Copy link

this is much needed

@RobinMalfait RobinMalfait changed the base branch from master to archive/master-2024-02-23 March 4, 2024 21:45
@silverwind
Copy link

Imho it shouldn't use @supports for the sake of keeping it lightweight and because @supports is known to have obscure bugs. Users should be aware of the browsers they support and if the prop is not supported, I would see it as graceful degradation.

@yuheiy
Copy link
Contributor

yuheiy commented Apr 12, 2024

There are subtle differences between the behavior of word-break: break-word and overflow-wrap: anywhere, so they should not be included in the same utility class. If the users want to progressively enhance, it should be the user’s responsibility.

Tailwind states the following regarding browser support:

Tailwind CSS v3.0 is primarily designed and tested with the latest stable versions of Chrome, Firefox, Edge, and Safari, and does not support any version of Internet Explorer, including IE 11.

While the majority of Tailwind CSS features are compatible with all modern browsers, the framework also incorporates APIs for several advanced features not yet universally supported, such as the :focus-visible pseudo-class and backdrop-filter utilities.

Given that Tailwind is a foundational framework, users can easily avoid using unsupported features by simply not utilizing the corresponding utility or modifier, similar to how one would refrain from using specific CSS features in their own stylesheets.

https://tailwindcss.com/docs/browser-support

For example, the support rate for text wrap utilities is lower, but this is not a problem. Whether or not to use those properties should be left to the user’s discretion.

@silverwind
Copy link

There are subtle differences between the behavior of word-break: break-word and overflow-wrap: anywhere, so they should not be included in the same utility class. If the users want to progressively enhance, it should be the user’s responsibility.

I agree and think this should just be .break-anywhere { overflow-wrap: anywhere }, let the user deal with the subtle differences and browser support instead of trying to be smart.

@liesahead
Copy link

liesahead commented Jul 12, 2024

Still very much needed.. It wouldn't be a problem if it was possible to redefine word break classes through tailwind config.

@silverwind
Copy link

silverwind commented Jul 12, 2024

Meanwhile, you can define a plugin in your config to add this. Here in the simplest variant:

import plugin from 'tailwindcss/plugin.js';

plugins: [
  plugin(({addUtilities}) => {
    addUtilities({
      '.break-anywhere': {
        'overflow-wrap': 'anywhere',
      },
    });
  }),
],

@sadeghi-aa
Copy link

Hi. Is there any update on this PR? I need the word-break: break-word; functionality. I did some research and found out that I can also use word-break: normal; in combination with overflow: anywhere; but the latter also doesn't exist in TailwindCSS. Does anyone have a solution for this issue?

@shrall
Copy link

shrall commented Aug 27, 2024

Hi. Is there any update on this PR? I need the word-break: break-word; functionality. I did some research and found out that I can also use word-break: normal; in combination with overflow: anywhere; but the latter also doesn't exist in TailwindCSS. Does anyone have a solution for this issue?

adding in a custom class just like @silverwind 's comment should work for now

@brandonmcconnell
Copy link
Contributor

@sadeghi-aa You could also use an arbitrary utility in the meantime, like [word-break:break-word]

@404missinglink
Copy link

Any update on merging this with base tailwind? Just went down such a huge rabbit hole since I didn't know break-word was deprecated and my iPhone users were complaining.

@sepehr-safari
Copy link

ship it!

@danielraab
Copy link

Why this pull request is into tailwindlabs:archive/master-2024-02-23 ?

@serkodev
Copy link
Author

@danielraab the old master branch renamed by the maintainers

@serkodev serkodev force-pushed the feat/break-anywhere branch from e02d323 to 13d7eef Compare November 30, 2024 13:07
@serkodev serkodev changed the base branch from archive/master-2024-02-23 to next November 30, 2024 13:07
@serkodev serkodev requested a review from a team as a code owner November 30, 2024 13:07
@francislavoie
Copy link

francislavoie commented Dec 3, 2024

I'd love to see this land for v4. This is the only usage of utilities we have in our project, so it would let us clean up at the same time as upgrading, instead of having to use the new @utilities in v4.

We're doing this as a workaround for now:

  plugins: [
    plugin(({addUtilities}) => {
      addUtilities({
        '.break-anywhere': {
          'overflow-wrap': 'anywhere',
        },
      });
    }),
  ],

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.