Chrome Subgrid Layout Examples

CSS Subgrid is one of the most powerful layout features to arrive in modern browsers, and Chrome has full support for it. If you have been struggling with nested grid alignments or want to create complex layouts where child elements inherit parent grid tracks, subgrid is the solution you need. This guide walks through practical Chrome subgrid layout examples that you can use in your projects today.

What Is Subgrid?

Before diving into examples, let us understand what makes subgrid special. Traditional CSS Grid allows you to create two-dimensional layouts with rows and columns. However, when you nest a grid inside a grid item, the inner grid loses its connection to the parent is rows and columns. Subgrid fixes this by allowing nested grids to inherit track sizes from their parent grid, enabling true alignment across nested layout levels.

Chrome added subgrid support starting with version 117, and it works alongside Firefox and Safari to provide cross-browser compatibility for this feature. To use subgrid, you create a parent grid with defined rows or columns, then use grid-template-rows: subgrid or grid-template-columns: subgrid on the child grid to inherit those tracks.

Example 1: Card Component with Aligned Headers

One of the most common use cases for subgrid is creating card layouts where all card headers align perfectly, even when the content varies in length. Without subgrid, you would need to manually set heights or use workarounds that break when content changes.

.card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.card {
  display: grid;
  grid-template-rows: subgrid;
  grid-row: span 3;
  background: #f5f5f5;
  border-radius: 8px;
  padding: 20px;
}

.card h2 {
  margin: 0 0 10px 0;
  font-size: 1.25rem;
}

In this example, the .card element uses grid-template-rows: subgrid to inherit the three row tracks from the parent .card-grid. This means all card titles will align at the same vertical position, regardless of how much text each card contains.

The HTML structure would look like this:

<div class="card-grid">
  <div class="card">
    <h2>Getting Started</h2>
    <p>Learn the basics of subgrid in Chrome.</p>
  </div>
  <div class="card">
    <h2>Advanced Techniques</h2>
    <p>Deep dive into complex layouts with nested subgrids.</p>
  </div>
  <div class="card">
    <h2>Best Practices</h2>
    <p>Tips for using subgrid effectively in production.</p>
  </div>
</div>

This pattern is incredibly useful for blog post cards, product listings, and dashboard widgets where visual consistency matters.

Example 2: Form Layout with Aligned Labels

Forms are another area where subgrid shines. Creating forms with consistently aligned labels and inputs across multiple sections traditionally required fixed heights or JavaScript calculations. Subgrid makes this straightforward.

.form-sections {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 40px;
}

.form-section {
  display: grid;
  grid-template-rows: subgrid;
  grid-row: span 4;
}

.form-group {
  display: flex;
  flex-direction: column;
}

label {
  font-weight: bold;
  margin-bottom: 5px;
  color: #333;
}

input, select, textarea {
  padding: 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
}

This example creates a two-column form where each section spans four rows. By using subgrid, all labels and inputs maintain consistent alignment across both columns, even when you have different numbers of form fields in each section.

Gallery layouts benefit tremendously from subgrid. When you have images of different aspect ratios with captions underneath, subgrid ensures all captions align horizontally while respecting the natural height of each image.

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  grid-auto-rows: auto;
}

.gallery-item {
  display: grid;
  grid-template-rows: subgrid;
  grid-row: span 2;
}

.gallery-item img {
  width: 100%;
  height: 200px;
  object-fit: cover;
  border-radius: 8px;
}

.caption {
  padding: 10px 0;
  font-size: 0.9rem;
  color: #666;
}

The grid-row: span 2 combined with subgrid ensures that the image takes up one track while the caption occupies the second track, creating consistent spacing between images and their descriptions.

Example 4: Dashboard Layout with Metric Cards

For dashboard interfaces showing metrics, KPIs, or statistics, subgrid helps create professional-looking layouts where numbers and labels align across all cards.

.dashboard {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: 80px 120px;
  gap: 20px;
}

.metric-card {
  display: grid;
  grid-template-rows: subgrid;
  grid-row: span 2;
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.metric-value {
  font-size: 2.5rem;
  font-weight: bold;
  color: #1a73e8;
}

.metric-label {
  color: #5f6368;
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

This creates a clean dashboard where all metric values align at the top and all labels align at the bottom, regardless of the number size. If you have a metric showing “1,234” next to one showing “9”, they will still look professionally aligned.

Example 5: Magazine-Style Article Layout

Subgrid enables sophisticated editorial layouts that were previously difficult to achieve without JavaScript or fixed dimensions. This example shows a magazine-style article with a featured image, headline, and metadata that align across multiple article cards.

.article-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  grid-template-rows: 60px auto 40px;
  gap: 30px;
}

.article-featured {
  display: grid;
  grid-template-rows: subgrid;
  grid-row: span 3;
}

.article-standard {
  display: grid;
  grid-template-rows: subgrid;
  grid-row: span 3;
}

.article-image {
  width: 100%;
  height: 250px;
  object-fit: cover;
  border-radius: 8px;
}

.article-category {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: #1a73e8;
  font-weight: bold;
}

.article-title {
  font-size: 1.5rem;
  margin: 10px 0;
}

.article-date {
  font-size: 0.8rem;
  color: #888;
}

The featured article takes up twice the width of standard articles, but all elements — category labels, titles, and dates — maintain perfect vertical alignment across the grid.

Browser Support and Progressive Enhancement

Chrome, Firefox, and Safari all support subgrid, meaning you can use it in production today. For older browsers, the layout gracefully degrades to a standard block layout, so your content remains accessible even if the precise alignment is lost.

To detect subgrid support, you can use a feature query:

@supports (grid-template-rows: subgrid) {
  .card {
    grid-template-rows: subgrid;
  }
}

This ensures your subgrid styles only apply where supported, while fallback styles work in older browsers.

Conclusion

These Chrome subgrid layout examples demonstrate how this feature solves real-world layout challenges. From aligning card components and form fields to creating sophisticated dashboards and editorial layouts, subgrid provides a CSS-only solution that previously required JavaScript or rigid structures.

The examples above are starting points you can adapt to your specific needs. As you work with subgrid, you will find even more creative ways to apply it, whether you are building simple card grids or complex multi-level layouts. For developers building Chrome extensions like Tab Suspender Pro, understanding CSS layout techniques like subgrid can help create more polished user interfaces with less JavaScript.


Built by theluckystrike — More tips at zovo.one