Skip to content

Commit 2eecb4d

Browse files
Remove max-w-auto and max-h-auto (#16917)
Closes #16916 This PR removes `max-w-auto` and `max-h-auto` due to them not being part of v3 and not being valid CSS: - https://developer.mozilla.org/en-US/docs/Web/CSS/max-width#syntax - https://developer.mozilla.org/en-US/docs/Web/CSS/max-height#syntax <img width="886" alt="Screenshot 2025-03-03 at 14 00 39" src="https://github.com/user-attachments/assets/2c7fa17c-975b-4e1f-ae56-99b703d6ca70" /> <img width="163" alt="Screenshot 2025-03-03 at 13 54 26" src="https://github.com/user-attachments/assets/12902a14-5a1e-4d7f-8127-fc2a3833221d" /> I decided to keep `max-w-auto` and `max-h-auto` since these values are valid even though these were not in v3 either: <img width="886" alt="Screenshot 2025-03-03 at 13 55 11" src="https://github.com/user-attachments/assets/83bf6543-06a3-429e-b39e-ef3ac3290f0b" />
1 parent fe9ab1e commit 2eecb4d

File tree

4 files changed

+14
-17
lines changed

4 files changed

+14
-17
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2525
- Ensure `outline-hidden` behaves like `outline-none` in non-`forced-colors` mode ([#](https://github.com/tailwindlabs/tailwindcss/pull/))
2626
- Allow `!important` on CSS variables again ([#16873](https://github.com/tailwindlabs/tailwindcss/pull/16873))
2727

28+
### Changed
29+
30+
- Removed `max-w-auto` and `max-h-auto` utilities as they generate invalid CSS ([#16917](https://github.com/tailwindlabs/tailwindcss/pull/16917))
31+
2832
## [4.0.9] - 2025-02-25
2933

3034
### Fixed

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

-2
Original file line numberDiff line numberDiff line change
@@ -5110,7 +5110,6 @@ exports[`getClassList 1`] = `
51105110
"max-h-9/12",
51115111
"max-h-10/12",
51125112
"max-h-11/12",
5113-
"max-h-auto",
51145113
"max-h-dvh",
51155114
"max-h-dvw",
51165115
"max-h-fit",
@@ -5158,7 +5157,6 @@ exports[`getClassList 1`] = `
51585157
"max-w-72",
51595158
"max-w-80",
51605159
"max-w-96",
5161-
"max-w-auto",
51625160
"max-w-dvh",
51635161
"max-w-dvw",
51645162
"max-w-fit",

packages/tailwindcss/src/utilities.test.ts

+5-12
Original file line numberDiff line numberDiff line change
@@ -2738,8 +2738,8 @@ test('min-width', async () => {
27382738
@tailwind utilities;
27392739
`,
27402740
[
2741-
'min-w-auto',
27422741
'min-w-full',
2742+
'min-w-auto',
27432743
'min-w-min',
27442744
'min-w-max',
27452745
'min-w-fit',
@@ -2813,16 +2813,7 @@ test('max-width', async () => {
28132813
}
28142814
@tailwind utilities;
28152815
`,
2816-
[
2817-
'max-w-none',
2818-
'max-w-full',
2819-
'max-w-max',
2820-
'max-w-max',
2821-
'max-w-fit',
2822-
'max-w-4',
2823-
'max-w-xl',
2824-
'max-w-[4px]',
2825-
],
2816+
['max-w-none', 'max-w-full', 'max-w-max', 'max-w-fit', 'max-w-4', 'max-w-xl', 'max-w-[4px]'],
28262817
),
28272818
).toMatchInlineSnapshot(`
28282819
":root, :host {
@@ -2861,6 +2852,7 @@ test('max-width', async () => {
28612852
expect(
28622853
await run([
28632854
'max-w',
2855+
'max-w-auto',
28642856
'-max-w-4',
28652857
'-max-w-[4px]',
28662858
'max-w-none/foo',
@@ -2988,8 +2980,8 @@ test('min-height', async () => {
29882980
@tailwind utilities;
29892981
`,
29902982
[
2991-
'min-h-auto',
29922983
'min-h-full',
2984+
'min-h-auto',
29932985
'min-h-screen',
29942986
'min-h-svh',
29952987
'min-h-lvh',
@@ -3145,6 +3137,7 @@ test('max-height', async () => {
31453137
expect(
31463138
await run([
31473139
'max-h',
3140+
'max-h-auto',
31483141
'-max-h-4',
31493142
'-max-h-[4px]',
31503143
'max-h-none/foo',

packages/tailwindcss/src/utilities.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -944,11 +944,13 @@ export function createUtilities(theme: Theme) {
944944
['height', value],
945945
])
946946
staticUtility(`w-${key}`, [['width', value]])
947-
staticUtility(`min-w-${key}`, [['min-width', value]])
948-
staticUtility(`max-w-${key}`, [['max-width', value]])
949947
staticUtility(`h-${key}`, [['height', value]])
948+
staticUtility(`min-w-${key}`, [['min-width', value]])
950949
staticUtility(`min-h-${key}`, [['min-height', value]])
951-
staticUtility(`max-h-${key}`, [['max-height', value]])
950+
if (key !== 'auto') {
951+
staticUtility(`max-w-${key}`, [['max-width', value]])
952+
staticUtility(`max-h-${key}`, [['max-height', value]])
953+
}
952954
}
953955

954956
staticUtility(`w-screen`, [['width', '100vw']])

0 commit comments

Comments
 (0)