DEV Community

Bootstrap 5 Grid System: The Complete Guide for 2026

I've been using Bootstrap's grid system since version 3. Watched it evolve from a 12-column float-based layout to a proper CSS Grid-powered system in Bootstrap 5. Most tutorials cover the basics - col-md-6, container, row. This one covers the parts developers actually get wrong and the features most people don't know exist.

The Container Options Nobody Explains Properly

Bootstrap 5 has three container types and the difference matters for layout.

  • .container - fixed max-width at each breakpoint. Your content has a maximum width and centers itself. Most common. Use for general page layouts.
  • .container-fluid - 100% width at all breakpoints. Full-width layouts. Use for dashboards where you want content to fill the screen.
  • .container-{breakpoint} - 100% width below the specified breakpoint, fixed max-width above it. This is the underused one.
<!-- Full width on mobile, fixed width on desktop -->
<div class="container-md">
  <!-- 100% width on xs and sm, fixed max-width on md and above -->
</div>

<!-- Full width until large screens -->
<div class="container-lg">
  <!-- Useful for dashboards that should fill tablet screens -->
</div>

For admin dashboards - container-fluid inside the main content area. For landing pages - container or container-lg. For hybrid layouts - container-{breakpoint} where the content transitions from full-width mobile to contained desktop.

Column Sizing - Beyond the Basics

Every developer knows col-md-6. Few know all the sizing options.

<!-- Auto-width - takes up as much space as content needs -->
<div class="row">
  <div class="col-auto">Auto width</div>
  <div class="col">Fills remaining space</div>
</div>

<!-- Equal width columns - no number needed -->
<div class="row">
  <div class="col">Equal</div>
  <div class="col">Equal</div>
  <div class="col">Equal</div>
</div>

<!-- Mixed - auto + fill -->
<div class="row align-items-center">
  <div class="col-auto">
    <img src="avatar.jpg" class="rounded-circle" width="40" height="40">
  </div>
  <div class="col">
    <h6 class="mb-0">User Name</h6>
    <small class="text-muted">u***@email.com</small>
  </div>
  <div class="col-auto">
    <span class="badge bg-success">Active</span>
  </div>
</div>

The col-auto + col pattern is the most useful for dashboard UI - avatar with auto width, name with fill, status badge with auto width. Eliminates manual width calculation for this common pattern.

Responsive Breakpoints - The Full Picture

Bootstrap 5 breakpoints:

Breakpoint Class infix Width
Extra small None (xs) < 576px
Small sm โ‰ฅ 576px
Medium md โ‰ฅ 768px
Large lg โ‰ฅ 992px
Extra large xl โ‰ฅ 1200px
Extra extra large xxl โ‰ฅ 1400px

The one developers miss - xxl. For large monitor dashboard layouts where you want a different column count above 1400px:

<!-- 1 col mobile, 2 col tablet, 3 col desktop, 4 col large desktop -->
<div class="row g-4">
  <div class="col-12 col-md-6 col-lg-4 col-xxl-3">
    <div class="stat-card card">...</div>
  </div>
</div>

For admin dashboards displayed on large monitors - col-xxl prevents wide cards that look wrong on 1440px+ screens.

Gutters - The Bootstrap 5 Improvement

Bootstrap 5 replaced padding-based gutters with the g-* utility. Most developers know g-4 but miss the directional variants.

<!-- Horizontal gutters only - useful for tight vertical layouts -->
<div class="row gx-4">
  <div class="col-md-6">...</div>
  <div class="col-md-6">...</div>
</div>

<!-- Vertical gutters only - when columns wrap and you need row spacing -->
<div class="row gy-3">
  <div class="col-md-4">...</div>
  <div class="col-md-4">...</div>
  <div class="col-md-4">...</div>
</div>

<!-- Both directions - most common for card grids -->
<div class="row g-4">
  <div class="col-md-4">...</div>
</div>

For stat card grids - g-4 (1.5rem gap both directions). For form layouts - gx-3 gy-2 (tighter vertical, comfortable horizontal). For full-width dashboard sections - gx-0 (no horizontal gap between edge-to-edge panels).

Offset and Order - When You Need Them

Offsets push columns to the right. Useful for centering a single column or creating asymmetric layouts.

<!-- Centered single column - login page pattern -->
<div class="row justify-content-center">
  <div class="col-md-6 col-lg-4">
    <div class="card">
      <div class="card-body"><!-- Login form --></div>
    </div>
  </div>
</div>

<!-- Offset - push column right -->
<div class="row">
  <div class="col-md-4 offset-md-4"><!-- Centered on md+ --></div>
</div>

Order utilities reorder columns visually without changing HTML order - important for accessibility where logical reading order matters:

<!-- On mobile: image first, text second -->
<!-- On desktop: text first, image second -->
<div class="row align-items-center">
  <div class="col-12 col-md-6 order-2 order-md-1">
    <h2>Headline</h2>
    <p>Description text</p>
  </div>
  <div class="col-12 col-md-6 order-1 order-md-2">
    <img src="illustration.svg" class="img-fluid">
  </div>
</div>

Screen readers follow DOM order - image first in this example. Visual layout shows text first on desktop. Both accessibility and design requirements satisfied.

Nested Grids for Complex Layouts

Nested rows inside columns give you 12 more columns to work with inside any column.

<div class="row g-4">
  <!-- Main content - 8 columns -->
  <div class="col-lg-8">
    <div class="row g-3">
      <!-- Nested 4 stat cards in the 8-column area -->
      <div class="col-6">
        <div class="stat-card card">
          <div class="card-body">
            <p class="text-muted small mb-1">Revenue</p>
            <h3>$48,295</h3>
          </div>
        </div>
      </div>
      <div class="col-6">
        <div class="stat-card card">
          <div class="card-body">
            <p class="text-muted small mb-1">Users</p>
            <h3>12,847</h3>
          </div>
        </div>
      </div>
      <!-- Full-width chart below stat cards -->
      <div class="col-12">
        <div class="card">
          <div class="card-body">
            <canvas id="revenueChart"></canvas>
          </div>
        </div>
      </div>
    </div>
  </div>
  <!-- Sidebar - 4 columns -->
  <div class="col-lg-4">
    <div class="card h-100">
      <div class="card-body"><!-- Recent activity feed --></div>
    </div>
  </div>
</div>

Nested grids are the correct approach for complex dashboard layouts - not position: absolute or manual pixel calculations.

The Dashboard Layout Pattern

A complete Bootstrap 5 admin dashboard layout using the grid properly:

<div class="dashboard-wrapper d-flex">
  <!-- Sidebar - fixed width, not part of grid -->
  <aside class="sidebar">
    <!-- Navigation -->
  </aside>
  <!-- Main content area - fills remaining space -->
  <main class="main-content flex-grow-1">
    <!-- Top navbar -->
    <nav class="navbar">...</nav>
    <!-- Page content - fluid container -->
    <div class="container-fluid p-4">
      <!-- Page header row -->
      <div class="row mb-4 align-items-center">
        <div class="col">
          <h1 class="h4 mb-0">Dashboard</h1>
          <nav aria-label="breadcrumb">
            <ol class="breadcrumb mb-0 small">
              <li class="breadcrumb-item">Home</li>
              <li class="breadcrumb-item active">Dashboard</li>
            </ol>
          </nav>
        </div>
        <div class="col-auto">
          <button class="btn btn-primary"><i class="bx bx-plus me-2"></i> New Report</button>
        </div>
      </div>
      <!-- Stat cards row -->
      <div class="row g-4 mb-4">
        <div class="col-12 col-sm-6 col-xxl-3">
          <div class="stat-card card border-0 shadow-sm">...</div>
        </div>
        <div class="col-12 col-sm-6 col-xxl-3">
          <div class="stat-card card border-0 shadow-sm">...</div>
        </div>
        <div class="col-12 col-sm-6 col-xxl-3">
          <div class="stat-card card border-0 shadow-sm">...</div>
        </div>
        <div class="col-12 col-sm-6 col-xxl-3">
          <div class="stat-card card border-0 shadow-sm">...</div>
        </div>
      </div>
      <!-- Charts and table row -->
      <div class="row g-4">
        <div class="col-12 col-xl-8">
          <div class="card border-0 shadow-sm">
            <div class="card-header bg-transparent border-0 pt-4 px-4">
              <h5 class="card-title mb-0">Revenue Overview</h5>
            </div>
            <div class="card-body">
              <canvas id="revenueChart" height="300"></canvas>
            </div>
          </div>
        </div>
        <div class="col-12 col-xl-4">
          <div class="card border-0 shadow-sm h-100">
            <div class="card-header bg-transparent border-0 pt-4 px-4">
              <h5 class="card-title mb-0">Recent Activity</h5>
            </div>
            <div class="card-body"><!-- Activity feed --></div>
          </div>
        </div>
      </div>
    </div>
  </main>
</div>

This is a complete, responsive dashboard layout. Mobile - single column, sidebar hidden. Tablet - sidebar visible, 2-column stat cards. Desktop - 4-column stat cards, 8/4 split for chart and activity feed. Large desktop - same layout with col-xxl-3 giving 4 equal stat cards. No custom CSS for the layout. Pure Bootstrap 5 grid. This is what the grid is designed for.

Browse Bootstrap 5 admin dashboard templates with proper grid implementation at LettStart Design - Bootstrap 5.3, zero jQuery, Lighthouse above 80. Use FIRST30 for 30% off.

Top comments (1) Useful overview, especially the responsive container and col-auto + col examples. One technical correction: Bootstrap 5โ€™s default .row / .col-* grid is still Flexbox-based, not CSS Grid-powered. The gutters also remain column padding offset by negative row margins; g-, gx-, and gy-* control those values rather than replacing the underlying mechanism. Iโ€™d also be cautious saying visual reordering automatically satisfies accessibility. DOM order remains the reading and often keyboard order, so the two layouts still need to preserve a meaningful sequence.

Comments

No comments yet. Start the discussion.