Skip to content

Commit 63b5cc2

Browse files
authored
Merge pull request #1284 from tailwindcss/max-w-screen
Add `max-w-screen-{breakpoint}` utilities
2 parents 2ae6c56 + 038b158 commit 63b5cc2

File tree

4 files changed

+187
-13
lines changed

4 files changed

+187
-13
lines changed

__tests__/fixtures/tailwind-output-important.css

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5117,6 +5117,22 @@ video {
51175117
max-width: 100% !important;
51185118
}
51195119

5120+
.max-w-screen-sm {
5121+
max-width: 640px !important;
5122+
}
5123+
5124+
.max-w-screen-md {
5125+
max-width: 768px !important;
5126+
}
5127+
5128+
.max-w-screen-lg {
5129+
max-width: 1024px !important;
5130+
}
5131+
5132+
.max-w-screen-xl {
5133+
max-width: 1280px !important;
5134+
}
5135+
51205136
.min-h-0 {
51215137
min-height: 0 !important;
51225138
}
@@ -14451,6 +14467,22 @@ video {
1445114467
max-width: 100% !important;
1445214468
}
1445314469

14470+
.sm\:max-w-screen-sm {
14471+
max-width: 640px !important;
14472+
}
14473+
14474+
.sm\:max-w-screen-md {
14475+
max-width: 768px !important;
14476+
}
14477+
14478+
.sm\:max-w-screen-lg {
14479+
max-width: 1024px !important;
14480+
}
14481+
14482+
.sm\:max-w-screen-xl {
14483+
max-width: 1280px !important;
14484+
}
14485+
1445414486
.sm\:min-h-0 {
1445514487
min-height: 0 !important;
1445614488
}
@@ -23786,6 +23818,22 @@ video {
2378623818
max-width: 100% !important;
2378723819
}
2378823820

23821+
.md\:max-w-screen-sm {
23822+
max-width: 640px !important;
23823+
}
23824+
23825+
.md\:max-w-screen-md {
23826+
max-width: 768px !important;
23827+
}
23828+
23829+
.md\:max-w-screen-lg {
23830+
max-width: 1024px !important;
23831+
}
23832+
23833+
.md\:max-w-screen-xl {
23834+
max-width: 1280px !important;
23835+
}
23836+
2378923837
.md\:min-h-0 {
2379023838
min-height: 0 !important;
2379123839
}
@@ -33121,6 +33169,22 @@ video {
3312133169
max-width: 100% !important;
3312233170
}
3312333171

33172+
.lg\:max-w-screen-sm {
33173+
max-width: 640px !important;
33174+
}
33175+
33176+
.lg\:max-w-screen-md {
33177+
max-width: 768px !important;
33178+
}
33179+
33180+
.lg\:max-w-screen-lg {
33181+
max-width: 1024px !important;
33182+
}
33183+
33184+
.lg\:max-w-screen-xl {
33185+
max-width: 1280px !important;
33186+
}
33187+
3312433188
.lg\:min-h-0 {
3312533189
min-height: 0 !important;
3312633190
}
@@ -42456,6 +42520,22 @@ video {
4245642520
max-width: 100% !important;
4245742521
}
4245842522

42523+
.xl\:max-w-screen-sm {
42524+
max-width: 640px !important;
42525+
}
42526+
42527+
.xl\:max-w-screen-md {
42528+
max-width: 768px !important;
42529+
}
42530+
42531+
.xl\:max-w-screen-lg {
42532+
max-width: 1024px !important;
42533+
}
42534+
42535+
.xl\:max-w-screen-xl {
42536+
max-width: 1280px !important;
42537+
}
42538+
4245942539
.xl\:min-h-0 {
4246042540
min-height: 0 !important;
4246142541
}

__tests__/fixtures/tailwind-output.css

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5117,6 +5117,22 @@ video {
51175117
max-width: 100%;
51185118
}
51195119

5120+
.max-w-screen-sm {
5121+
max-width: 640px;
5122+
}
5123+
5124+
.max-w-screen-md {
5125+
max-width: 768px;
5126+
}
5127+
5128+
.max-w-screen-lg {
5129+
max-width: 1024px;
5130+
}
5131+
5132+
.max-w-screen-xl {
5133+
max-width: 1280px;
5134+
}
5135+
51205136
.min-h-0 {
51215137
min-height: 0;
51225138
}
@@ -14451,6 +14467,22 @@ video {
1445114467
max-width: 100%;
1445214468
}
1445314469

14470+
.sm\:max-w-screen-sm {
14471+
max-width: 640px;
14472+
}
14473+
14474+
.sm\:max-w-screen-md {
14475+
max-width: 768px;
14476+
}
14477+
14478+
.sm\:max-w-screen-lg {
14479+
max-width: 1024px;
14480+
}
14481+
14482+
.sm\:max-w-screen-xl {
14483+
max-width: 1280px;
14484+
}
14485+
1445414486
.sm\:min-h-0 {
1445514487
min-height: 0;
1445614488
}
@@ -23786,6 +23818,22 @@ video {
2378623818
max-width: 100%;
2378723819
}
2378823820

23821+
.md\:max-w-screen-sm {
23822+
max-width: 640px;
23823+
}
23824+
23825+
.md\:max-w-screen-md {
23826+
max-width: 768px;
23827+
}
23828+
23829+
.md\:max-w-screen-lg {
23830+
max-width: 1024px;
23831+
}
23832+
23833+
.md\:max-w-screen-xl {
23834+
max-width: 1280px;
23835+
}
23836+
2378923837
.md\:min-h-0 {
2379023838
min-height: 0;
2379123839
}
@@ -33121,6 +33169,22 @@ video {
3312133169
max-width: 100%;
3312233170
}
3312333171

33172+
.lg\:max-w-screen-sm {
33173+
max-width: 640px;
33174+
}
33175+
33176+
.lg\:max-w-screen-md {
33177+
max-width: 768px;
33178+
}
33179+
33180+
.lg\:max-w-screen-lg {
33181+
max-width: 1024px;
33182+
}
33183+
33184+
.lg\:max-w-screen-xl {
33185+
max-width: 1280px;
33186+
}
33187+
3312433188
.lg\:min-h-0 {
3312533189
min-height: 0;
3312633190
}
@@ -42456,6 +42520,22 @@ video {
4245642520
max-width: 100%;
4245742521
}
4245842522

42523+
.xl\:max-w-screen-sm {
42524+
max-width: 640px;
42525+
}
42526+
42527+
.xl\:max-w-screen-md {
42528+
max-width: 768px;
42529+
}
42530+
42531+
.xl\:max-w-screen-lg {
42532+
max-width: 1024px;
42533+
}
42534+
42535+
.xl\:max-w-screen-xl {
42536+
max-width: 1280px;
42537+
}
42538+
4245942539
.xl\:min-h-0 {
4246042540
min-height: 0;
4246142541
}

src/util/resolveConfig.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,17 @@ const configUtils = {
2020
{}
2121
)
2222
},
23+
breakpoints(screens) {
24+
return Object.keys(screens)
25+
.filter(key => typeof screens[key] === 'string')
26+
.reduce(
27+
(breakpoints, key) => ({
28+
...breakpoints,
29+
[`screen-${key}`]: screens[key],
30+
}),
31+
{}
32+
)
33+
},
2334
}
2435

2536
function value(valueToResolve, ...args) {

stubs/defaultConfig.stub.js

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -302,19 +302,22 @@ module.exports = {
302302
full: '100%',
303303
screen: '100vh',
304304
},
305-
maxWidth: {
306-
none: 'none',
307-
xs: '20rem',
308-
sm: '24rem',
309-
md: '28rem',
310-
lg: '32rem',
311-
xl: '36rem',
312-
'2xl': '42rem',
313-
'3xl': '48rem',
314-
'4xl': '56rem',
315-
'5xl': '64rem',
316-
'6xl': '72rem',
317-
full: '100%',
305+
maxWidth: (theme, { breakpoints }) => {
306+
return {
307+
none: 'none',
308+
xs: '20rem',
309+
sm: '24rem',
310+
md: '28rem',
311+
lg: '32rem',
312+
xl: '36rem',
313+
'2xl': '42rem',
314+
'3xl': '48rem',
315+
'4xl': '56rem',
316+
'5xl': '64rem',
317+
'6xl': '72rem',
318+
full: '100%',
319+
...breakpoints(theme('screens')),
320+
}
318321
},
319322
minHeight: {
320323
'0': '0',

0 commit comments

Comments
 (0)