Skip to content

Commit 1eab49d

Browse files
authored
Sort text wrapping utilities with typography utilities (#14787)
This PR implements some changes to the way we sort typography utilities, inspired by #14715. Prior to this PR, utilities like `text-balance`, `break-words`, and `text-center` were sorted very early, even before things like border utilities: ```html <div class="text-balance break-words border-2 border-blue-500 text-center indent-5 text-2xl font-medium capitalize leading-6 tracking-tight text-red-500 underline"></div> ``` This PR changes the sort order to co-locate these with other typography utilities which feels a lot more natural: ```html <div class="border-2 border-blue-500 text-center indent-5 text-2xl leading-6 font-medium tracking-tight text-balance break-words text-red-500 capitalize underline"></div> ``` I've also made some small adjustments to how other typography properties are sorted based on pairing with @reinink and just deciding what felt the most intuitive to us and matched the order we'd likely type things in manually. To test this change I temporarily added a new test to `sort.test.ts` to make sure the classes were sorted in the expected order: ```js [ // Input 'text-red-500 text-center capitalize text-2xl break-words text-balance underline font-medium tracking-tight leading-6 indent-5', // Expected 'text-center indent-5 text-2xl leading-6 font-medium tracking-tight text-balance break-words text-red-500 capitalize underline', ], ``` Didn't keep the test around because there's no real logic to test here (it just matches the order in the `property-order.ts` file) and we don't have any other tests like this. I've also made some minor unrelated changes here like deleting legacy properties from `property-order.ts` that are never used, and fixing a typo where we wrote `work-break` instead of `word-break`. --------- Co-authored-by: Adam Wathan <4323180+adamwathan@users.noreply.github.com>
1 parent 3fe53dd commit 1eab49d

File tree

2 files changed

+13
-19
lines changed

2 files changed

+13
-19
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2828
### Changed
2929

3030
- Don't convert underscores in the first argument to `var()` and `theme()` to spaces ([#14776](https://github.com/tailwindlabs/tailwindcss/pull/14776), [#14781](https://github.com/tailwindlabs/tailwindcss/pull/14781))
31+
- Sort text alignment and wrapping utilities with typography utilities ([#14787](https://github.com/tailwindlabs/tailwindcss/pull/14787))
32+
- Sort line height and letter spacing utilities before text color utilities ([#14787](https://github.com/tailwindlabs/tailwindcss/pull/14787))
3133

3234
## [4.0.0-alpha.29] - 2024-10-23
3335

packages/tailwindcss/src/property-order.ts

+11-19
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,6 @@ export default [
155155
'--tw-divide-y-reverse',
156156
'divide-style',
157157
'divide-color',
158-
'--tw-divide-opacity',
159158

160159
'place-self',
161160
'align-self',
@@ -171,14 +170,6 @@ export default [
171170

172171
'scroll-behavior',
173172

174-
'text-overflow',
175-
'hyphens',
176-
'white-space',
177-
178-
'text-wrap',
179-
'overflow-wrap',
180-
'work-break',
181-
182173
'border-radius',
183174
'border-start-radius', // Not real
184175
'border-end-radius', // Not real
@@ -215,10 +206,7 @@ export default [
215206
'border-bottom-color',
216207
'border-left-color',
217208

218-
'--tw-border-opacity',
219-
220209
'background-color',
221-
'--tw-bg-opacity',
222210

223211
'background-image',
224212
'--tw-gradient-position',
@@ -263,24 +251,29 @@ export default [
263251

264252
'font-family',
265253
'font-size',
254+
'line-height',
266255
'font-weight',
256+
'letter-spacing',
257+
'text-wrap',
258+
'overflow-wrap',
259+
'word-break',
260+
'text-overflow',
261+
'hyphens',
262+
'white-space',
263+
264+
'color',
267265
'text-transform',
268266
'font-style',
269267
'font-stretch',
270268
'font-variant-numeric',
271-
'line-height',
272-
'letter-spacing',
273-
'color',
274-
'--tw-text-opacity',
275269
'text-decoration-line',
276270
'text-decoration-color',
277271
'text-decoration-style',
278272
'text-decoration-thickness',
279273
'text-underline-offset',
280274
'-webkit-font-smoothing',
281275

282-
'placeholder-color', // Not real
283-
'--tw-placeholder-opacity',
276+
'placeholder-color',
284277

285278
'caret-color',
286279
'accent-color',
@@ -301,7 +294,6 @@ export default [
301294
'--tw-inset-shadow-color',
302295
'--tw-inset-ring-shadow',
303296
'--tw-inset-ring-color',
304-
'--tw-ring-opacity',
305297
'--tw-ring-offset-width',
306298
'--tw-ring-offset-color',
307299

0 commit comments

Comments
 (0)