Kombai Logo

Tailwind CSS Grid Row

Grid Row in CSS refers to how an item in a grid layout is placed across vertical tracks. By defining explicit row boundaries, you can easily control how many rows an element spans and where it begins or ends within the grid. Tailwind includes a variety of row-based classes that enable you to quickly specify row start and end positions.

In this guide, we will learn how to effectively work with these utilities in Tailwind CSS, their conditional & responsive application, and how to use custom grid-row utilities.

ClassPropertiesExample
row-autogrid-row: auto;<div className="row-auto"></div>
row-span-1grid-row: span 1 / span 1;<div className="row-span-1"></div>
row-span-2grid-row: span 2 / span 2;<div className="row-span-2"></div>
row-span-3grid-row: span 3 / span 3;<div className="row-span-3"></div>
row-span-4grid-row: span 4 / span 4;<div className="row-span-4"></div>
row-span-5grid-row: span 5 / span 5;<div className="row-span-5"></div>
row-span-6grid-row: span 6 / span 6;<div className="row-span-6"></div>
row-span-7grid-row: span 7 / span 7;<div className="row-span-7"></div>
row-span-8grid-row: span 8 / span 8;<div className="row-span-8"></div>
row-span-9grid-row: span 9 / span 9;<div className="row-span-9"></div>
row-span-10grid-row: span 10 / span 10;<div className="row-span-10"></div>
row-span-11grid-row: span 11 / span 11;<div className="row-span-11"></div>
row-span-12grid-row: span 12 / span 12;<div className="row-span-12"></div>
row-span-fullgrid-row: 1 / -1;<div className="row-span-full"></div>
row-start-1grid-row-start: 1;<div className="row-start-1"></div>
row-start-2grid-row-start: 2;<div className="row-start-2"></div>
row-start-3grid-row-start: 3;<div className="row-start-3"></div>
row-start-4grid-row-start: 4;<div className="row-start-4"></div>
row-start-5grid-row-start: 5;<div className="row-start-5"></div>
row-start-6grid-row-start: 6;<div className="row-start-6"></div>
row-start-7grid-row-start: 7;<div className="row-start-7"></div>
row-start-8grid-row-start: 8;<div className="row-start-8"></div>
row-start-9grid-row-start: 9;<div className="row-start-9"></div>
row-start-10grid-row-start: 10;<div className="row-start-10"></div>
row-start-11grid-row-start: 11;<div className="row-start-11"></div>
row-start-12grid-row-start: 12;<div className="row-start-12"></div>
row-start-13grid-row-start: 13;<div className="row-start-13"></div>
row-start-autogrid-row-start: auto;<div className="row-start-auto"></div>
row-end-1grid-row-end: 1;<div className="row-end-1"></div>
row-end-2grid-row-end: 2;<div className="row-end-2"></div>
row-end-3grid-row-end: 3;<div className="row-end-3"></div>
row-end-4grid-row-end: 4;<div className="row-end-4"></div>
row-end-5grid-row-end: 5;<div className="row-end-5"></div>
row-end-6grid-row-end: 6;<div className="row-end-6"></div>
row-end-7grid-row-end: 7;<div className="row-end-7"></div>
row-end-8grid-row-end: 8;<div className="row-end-8"></div>
row-end-9grid-row-end: 9;<div className="row-end-9"></div>
row-end-10grid-row-end: 10;<div className="row-end-10"></div>
row-end-11grid-row-end: 11;<div className="row-end-11"></div>
row-end-12grid-row-end: 12;<div className="row-end-12"></div>
row-end-13grid-row-end: 13;<div className="row-end-13"></div>
row-end-autogrid-row-end: auto;<div className="row-end-auto"></div>

Overview of Grid Row

Spanning multiple rows

When you want an element to extend vertically across multiple grid tracks, you can specify a row span. For instance, row-span-2 instructs the element to occupy two rows. This is especially handy if you have content that naturally grows taller than surrounding elements or when you want a highlight section that is visually distinct by spanning a greater vertical height.

This is a live editor. Play around with it!
export default function App() {
  return <h1>Hello world</h1>
}

Adding the start and end lines

For even finer control, Tailwind offers utilities for specifying explicit start and end line numbers. This provides a direct mapping to CSS properties like:

  • grid-row-start: <line>
  • grid-row-end: <line>

By assigning row-start-* and row-end-*, you don't necessarily have to rely on span. You can explicitly target row lines in the grid, e.g., start at row 1 and end at row 3 (row-start-1 row-end-3). This precision is invaluable when designing label-like sections or anchoring items in very particular vertical segments.

This is a live editor. Play around with it!
export default function App() {
  return <h1>Hello world</h1>
}

States and Responsiveness

Hover and Focus States

Tailwind’s modifiers such as hover and focus, let you adapt an element’s row positioning upon user interaction. You can, for instance, cause an element to shift its row start on hover or span multiple rows only on focus.

This is a live editor. Play around with it!
export default function App() {
  return <h1>Hello world</h1>
}

Breakpoint Modifiers

Tailwind CSS provides breakpoint modifiers to conditionally apply the utility only when the screen hits the defined breakpoint. This is especially helpful for changing the grid-row only on specific screens. Use Tailwind's breakpoint modifiers like- sm, md, etc., to apply the utility only on these breakpoints and above.

This is a live editor. Play around with it!
export default function App() {
  return <h1>Hello world</h1>
}

Custom Grid Row

Extending the Theme

Tailwind’s configuration file (tailwind.config.js) allows you to extend or override the default theme values for row-based utilities. By customizing the theme, you can define new row spans or line start/end values that match your project’s unique design system.

This is a live editor. Play around with it!
export default function App() {
  return <h1>Hello world</h1>
}

Using Arbitrary Values

In addition to theme extension, Tailwind offers arbitrary values for utilities. This is particularly advantageous when you need to quickly experiment with new grid line configurations without editing your theme configuration. Arbitrary values let you specify the property value inline using a square bracket syntax.

This is a live editor. Play around with it!
export default function App() {
  return <h1>Hello world</h1>
}

Real World Examples

Dynamic Content Feed

A compact social media-style feed with featured posts spanning multiple rows.

This is a live editor. Play around with it!
export default function App() {
  return <h1>Hello world</h1>
}

Project Board

A compact project management board with tasks spanning different row heights based on priority and content.

This is a live editor. Play around with it!
export default function App() {
  return <h1>Hello world</h1>
}

An image gallery where certain images span multiple rows to create visual hierarchy and interest.

This is a live editor. Play around with it!
export default function App() {
  return <h1>Hello world</h1>
}

Dashboard Stats

A metrics dashboard with varied row spans to show different levels of data detail and importance.

This is a live editor. Play around with it!
export default function App() {
  return <h1>Hello world</h1>
}

Team Directory Extended

A team directory with varied row spans to show different levels of leadership and responsibility.

This is a live editor. Play around with it!
export default function App() {
  return <h1>Hello world</h1>
}

Customization Examples

A compact photo gallery with featured images spanning multiple rows.

This is a live editor. Play around with it!
export default function App() {
  return <h1>Hello world</h1>
}

Dashboard Stats

A minimal dashboard with widgets using custom row spans.

This is a live editor. Play around with it!
export default function App() {
  return <h1>Hello world</h1>
}

News Cards

A condensed news feed with articles in custom row positions.

This is a live editor. Play around with it!
export default function App() {
  return <h1>Hello world</h1>
}

Best Practices

Maintain Design Consistency

Maintaining consistency in your project is essential when applying row-span-*, row-start-*, and row-end-* utilities. One effective method is defining a standard grid template and sticking to predetermined row spans to align content predictably. Overuse of irregular spans can introduce inconsistency, making the layout harder to manage.

Use Tailwind’s predefined spacing and alignment utilities to further reinforce a consistent look and feel. When structuring your design, consider keeping uniformity in row spans and ensuring elements within a grid share similar spacing and alignment.

Leverage Utility Combinations

Combining multiple Tailwind utilities allows you to build powerful grid-based layouts without unnecessary complexity. For instance, pairing row-span-* with col-span-* enables dynamic content positioning that adheres to a structured framework. When used thoughtfully, these combinations can streamline content presentation, making interfaces more readable and functional.

For better clarity, consider integrating utilities such as gap-* to control spacing between rows efficiently. Using justify-items-* or align-items-* can fine-tune how content is aligned within each grid row, ensuring that the layout remains visually balanced. Additionally, pairing row-start-* and row-end-* with col-start-* and col-end-* helps create a seamless content flow that aligns well with design expectations.

Accessibility Considerations

Enhance Readability and Navigability

Maintaining predictable row structures is key to keeping readability intact. By defining consistent row spans and ensuring elements align properly within their designated spaces, content remains easy to digest. Spacing between rows also plays an important role—using Tailwind’s gap-* utilities alongside row-span-* can help create distinct separations that visually segment content without overwhelming the user.

Additionally, ensuring an intuitive reading flow from one row to the next helps users quickly locate and interpret information without unnecessary scanning.

Focus on High Contrast

Maintaining adequate contrast between row-separated elements enhances content visibility and prevents information from blending into the background. Incorporating border-* and gap-* utilities can further emphasize separation between content blocks, making them easier to distinguish and navigate.

A useful approach is to apply bg-* and text-* utilities alongside row-span-* to create clear distinctions between content sections. Additionally, using border-* utilities allows you to create subtle visual dividers that segment different elements while maintaining design harmony.

For better accessibility, it’s also important to evaluate how grid row configurations affect user interaction. Using accessible color schemes, background contrasts, and well-placed borders allows users with visual impairments to distinguish content without unnecessary strain.