Skip to content

Commit 62d3e74

Browse files
Add wrap-anywhere utility (#12128)
Related discussion #12127 ```css .wrap-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. --------- Co-authored-by: Philipp Spiess <[email protected]>
1 parent 419b3dc commit 62d3e74

File tree

5 files changed

+41
-4
lines changed

5 files changed

+41
-4
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Added
1111

1212
- _Experimental_: Add `user-valid` and `user-invalid` variants ([#12370](https://github.com/tailwindlabs/tailwindcss/pull/12370))
13+
- _Experimental_: Add `wrap-anywhere`, `wrap-break-word`, and `wrap-normal` utilities ([#12128](https://github.com/tailwindlabs/tailwindcss/pull/12128))
1314

1415
## [4.0.8] - 2025-02-21
1516

packages/tailwindcss/src/__snapshots__/intellisense.test.ts.snap

+3
Original file line numberDiff line numberDiff line change
@@ -8350,6 +8350,9 @@ exports[`getClassList 1`] = `
83508350
"will-change-contents",
83518351
"will-change-scroll",
83528352
"will-change-transform",
8353+
"wrap-anywhere",
8354+
"wrap-break-word",
8355+
"wrap-normal",
83538356
"z-0",
83548357
"z-10",
83558358
"z-20",
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export const enableUserValid = process.env.FEATURES_ENV !== 'stable'
2+
export const enableWrapAnywhere = process.env.FEATURES_ENV !== 'stable'

packages/tailwindcss/src/utilities.test.ts

+29-4
Original file line numberDiff line numberDiff line change
@@ -4213,9 +4213,8 @@ test('translate-y', async () => {
42134213
})
42144214

42154215
test('translate-z', async () => {
4216-
expect(
4217-
await run(['-translate-z-px', 'translate-z-px', '-translate-z-[var(--value)]']),
4218-
).toMatchInlineSnapshot(`
4216+
expect(await run(['-translate-z-px', 'translate-z-px', '-translate-z-[var(--value)]']))
4217+
.toMatchInlineSnapshot(`
42194218
".-translate-z-\\[var\\(--value\\)\\] {
42204219
--tw-translate-z: calc(var(--value) * -1);
42214220
translate: var(--tw-translate-x) var(--tw-translate-y) var(--tw-translate-z);
@@ -8800,7 +8799,7 @@ test('text-wrap', async () => {
88008799
).toEqual('')
88018800
})
88028801

8803-
test('overflow-wrap', async () => {
8802+
test('word-break', async () => {
88048803
expect(await run(['break-normal', 'break-words', 'break-all', 'break-keep']))
88058804
.toMatchInlineSnapshot(`
88068805
".break-normal {
@@ -8834,6 +8833,32 @@ test('overflow-wrap', async () => {
88348833
).toEqual('')
88358834
})
88368835

8836+
test('overflow-wrap', async () => {
8837+
expect(await run(['wrap-anywhere', 'wrap-break-word', 'wrap-normal'])).toMatchInlineSnapshot(`
8838+
".wrap-anywhere {
8839+
overflow-wrap: anywhere;
8840+
}
8841+
8842+
.wrap-break-word {
8843+
overflow-wrap: break-word;
8844+
}
8845+
8846+
.wrap-normal {
8847+
overflow-wrap: normal;
8848+
}"
8849+
`)
8850+
expect(
8851+
await run([
8852+
'-wrap-anywhere',
8853+
'-wrap-break-word',
8854+
'-wrap-normal',
8855+
'wrap-anywhere/foo',
8856+
'wrap-break-word/foo',
8857+
'wrap-normal/foo',
8858+
]),
8859+
).toEqual('')
8860+
})
8861+
88378862
test('rounded', async () => {
88388863
expect(
88398864
await compileCss(

packages/tailwindcss/src/utilities.ts

+7
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
} from './ast'
1212
import type { Candidate, CandidateModifier, NamedUtilityValue } from './candidate'
1313
import type { DesignSystem } from './design-system'
14+
import { enableWrapAnywhere } from './feature-flags'
1415
import type { Theme, ThemeKey } from './theme'
1516
import { compareBreakpoints } from './utils/compare-breakpoints'
1617
import { DefaultMap } from './utils/default-map'
@@ -2029,6 +2030,12 @@ export function createUtilities(theme: Theme) {
20292030
staticUtility('break-all', [['word-break', 'break-all']])
20302031
staticUtility('break-keep', [['word-break', 'keep-all']])
20312032

2033+
if (enableWrapAnywhere) {
2034+
staticUtility('wrap-anywhere', [['overflow-wrap', 'anywhere']])
2035+
staticUtility('wrap-break-word', [['overflow-wrap', 'break-word']])
2036+
staticUtility('wrap-normal', [['overflow-wrap', 'normal']])
2037+
}
2038+
20322039
{
20332040
// border-radius
20342041
for (let [root, properties] of [

0 commit comments

Comments
 (0)