@@ -378,17 +378,51 @@ export const alignSelfRule: UtilityRule = (parsed) => {
378378 }
379379}
380380
381- // Container utility
382- // TODO: Requires nested media query support in generator
383- export const containerRule : UtilityRule = ( parsed , _config ) => {
384- if ( parsed . utility === 'container' && ! parsed . value ) {
385- // Simplified version without responsive max-widths
386- return {
387- 'width' : '100%' ,
388- 'margin-left' : 'auto' ,
389- 'margin-right' : 'auto' ,
390- 'padding-left' : '1rem' ,
391- 'padding-right' : '1rem' ,
381+ // Container utility with responsive max-widths
382+ export const containerRule : UtilityRule = ( parsed , config ) => {
383+ if ( parsed . utility === 'container' ) {
384+ // container without value - centered container with responsive max-width
385+ if ( ! parsed . value ) {
386+ // Use clamp for modern responsive max-width behavior
387+ // Max-width scales with breakpoints: sm=640, md=768, lg=1024, xl=1280, 2xl=1536
388+ const xl = config . theme . screens [ 'xl' ] || '1280px'
389+ return {
390+ 'width' : '100%' ,
391+ 'margin-left' : 'auto' ,
392+ 'margin-right' : 'auto' ,
393+ 'max-width' : xl ,
394+ }
395+ }
396+
397+ // container-{breakpoint} for specific max-widths
398+ const breakpointMap : Record < string , string > = {
399+ 'sm' : config . theme . screens [ 'sm' ] || '640px' ,
400+ 'md' : config . theme . screens [ 'md' ] || '768px' ,
401+ 'lg' : config . theme . screens [ 'lg' ] || '1024px' ,
402+ 'xl' : config . theme . screens [ 'xl' ] || '1280px' ,
403+ '2xl' : config . theme . screens [ '2xl' ] || '1536px' ,
404+ 'full' : '100%' ,
405+ 'prose' : '65ch' ,
406+ '3xl' : '1920px' ,
407+ }
408+
409+ if ( breakpointMap [ parsed . value ] ) {
410+ return {
411+ 'width' : '100%' ,
412+ 'margin-left' : 'auto' ,
413+ 'margin-right' : 'auto' ,
414+ 'max-width' : breakpointMap [ parsed . value ] ,
415+ }
416+ }
417+
418+ // Arbitrary value support: container-[800px]
419+ if ( parsed . arbitrary ) {
420+ return {
421+ 'width' : '100%' ,
422+ 'margin-left' : 'auto' ,
423+ 'margin-right' : 'auto' ,
424+ 'max-width' : parsed . value ,
425+ }
392426 }
393427 }
394428}
0 commit comments