Skip to content

Container

The Container component provides responsive layout containers that help center and horizontally pad your content. It’s a fundamental building block for creating responsive layouts in Metro UI.

This component has no external dependencies beyond the core Metro UI framework.

<div class="container">
<!-- Your content here -->
</div>

For a full-width container that spans the entire viewport width:

<div class="container-fluid">
<!-- Your content here -->
</div>

For containers with specific maximum widths:

<div class="container-xs"><!-- Max-width based on xs breakpoint --></div>
<div class="container-sm"><!-- Max-width based on sm breakpoint --></div>
<div class="container-md"><!-- Max-width based on md breakpoint --></div>
<div class="container-lg"><!-- Max-width based on lg breakpoint --></div>
<div class="container-xl"><!-- Max-width based on xl breakpoint --></div>
<div class="container-xxl"><!-- Max-width based on xxl breakpoint --></div>

For a container that takes 100% width:

<div class="container-max">
<!-- Your content here -->
</div>

For containers that support CSS container queries:

<div class="container-query">
<!-- Content that can respond to container size -->
</div>
<div class="responsive-container">
<!-- Content that can respond to container size -->
</div>

The container styles are also applied to the following semantic HTML elements:

<header><!-- Header content --></header>
<section><!-- Section content --></section>
<footer><!-- Footer content --></footer>
<aside><!-- Sidebar content --></aside>

The Container component doesn’t use CSS variables for styling. Its behavior is controlled through media queries and fixed values.

You can customize the container’s padding:

.container {
padding-left: 20px;
padding-right: 20px;
}
  • .container - Standard responsive container with adaptive max-width
  • .container-fluid - Full-width container with no max-width
  • .container-max - Full-width container (100%)
  • .container-query, .responsive-container - Containers with CSS container query support
  • .container-xs - Container with max-width set to xs breakpoint
  • .container-sm - Container with max-width set to sm breakpoint
  • .container-md - Container with max-width set to md breakpoint
  • .container-lg - Container with max-width set to lg breakpoint
  • .container-xl - Container with max-width set to xl breakpoint
  • .container-xxl - Container with max-width set to xxl breakpoint

The standard .container class has the following responsive behavior:

Viewport WidthContainer Max Width
< 360px100%
360px - 576px98%
577px - 768px95%
769px - 992px90%
993px - 1200px90%
> 1200px80%

The .container-query and .responsive-container classes enable CSS container queries, allowing child elements to respond to the container’s size rather than the viewport size:

/* Example of using container queries */
@container container-query (min-width: 400px) {
.responsive-element {
font-size: 1.2rem;
}
}
  • Responsive containers that adapt to different screen sizes
  • Fluid container option for full-width layouts
  • Fixed-width container options for specific breakpoints
  • Container query support for component-level responsiveness
  • Consistent padding on left and right sides (12px by default)
  • Automatic centering with margin: 0 auto
  • Relative positioning, allowing absolute positioning of child elements