Flexbox & Grid

Grid Row Start / End

Utilities for controlling how elements are sized and placed across grid rows.

Quick reference

Class
Properties
row-autogrid-row: auto;
row-span-1grid-row: span 1 / span 1;
row-span-2grid-row: span 2 / span 2;
row-span-3grid-row: span 3 / span 3;
row-span-4grid-row: span 4 / span 4;
row-span-5grid-row: span 5 / span 5;
row-span-6grid-row: span 6 / span 6;
row-span-fullgrid-row: 1 / -1;
row-start-1grid-row-start: 1;
row-start-2grid-row-start: 2;
row-start-3grid-row-start: 3;
row-start-4grid-row-start: 4;
row-start-5grid-row-start: 5;
row-start-6grid-row-start: 6;
row-start-7grid-row-start: 7;
row-start-autogrid-row-start: auto;
row-end-1grid-row-end: 1;
row-end-2grid-row-end: 2;
row-end-3grid-row-end: 3;
row-end-4grid-row-end: 4;
row-end-5grid-row-end: 5;
row-end-6grid-row-end: 6;
row-end-7grid-row-end: 7;
row-end-autogrid-row-end: auto;

Show all classes

Basic usage

Spanning rows

Use the row-span-{n} utilities to make an element span n rows.

Grid Row Start / End - 图1

  1. <div class="grid grid-rows-3 grid-flow-col gap-4">
  2. <div class="row-span-3 ...">01</div>
  3. <div class="col-span-2 ...">02</div>
  4. <div class="row-span-2 col-span-2 ...">03</div>
  5. </div>

Starting and ending lines

Use the row-start-{n} and row-end-{n} utilities to make an element start or end at the nth grid line. These can also be combined with the row-span-{n} utilities to span a specific number of rows.

Note that CSS grid lines start at 1, not 0, so a full-height element in a 3-row grid would start at line 1 and end at line 4.

Grid Row Start / End - 图2

  1. <div class="grid grid-rows-3 grid-flow-col gap-4">
  2. <div class="row-start-2 row-span-2 ...">01</div>
  3. <div class="row-end-3 row-span-2 ...">02</div>
  4. <div class="row-start-1 row-end-4 ...">03</div>
  5. </div>

Applying conditionally

Hover, focus, and other states

Tailwind lets you conditionally apply utility classes in different states using variant modifiers. For example, use hover:row-span-4 to only apply the row-span-4 utility on hover.

  1. <div class="row-span-3 hover:row-span-4">
  2. <!-- ... -->
  3. </div>

For a complete list of all available state modifiers, check out the Hover, Focus, & Other States documentation.

Breakpoints and media queries

You can also use variant modifiers to target media queries like responsive breakpoints, dark mode, prefers-reduced-motion, and more. For example, use md:row-span-4 to apply the row-span-4 utility at only medium screen sizes and above.

  1. <div class="row-span-3 md:row-span-4">
  2. <!-- ... -->
  3. </div>

To learn more, check out the documentation on Responsive Design, Dark Mode and other media query modifiers.


Using custom values

Customizing your theme

By default, Tailwind includes grid-row utilities for working with grids with up to 6 explicit rows. You can customize these values by editing theme.gridRow, theme.extend.gridRow, theme.gridRowStart, theme.extend.gridRowStart, theme.gridRowEnd, and theme.extend.gridRowEnd in your tailwind.config.js file.

For creating more row-{value} utilities that control the grid-row shorthand property directly, customize the gridRow section of your Tailwind theme config:

tailwind.config.js

  1. module.exports = {
  2. theme: {
  3. extend: {
  4. gridRow: {
  5. 'span-16': 'span 16 / span 16',
  6. }
  7. }
  8. }
  9. }

We use this internally for our row-span-{n} utilities. Note that since this configures the grid-row shorthand property directly, we include the word span directly in the value name, it’s not baked into the class name automatically. That means you are free to add entries that do whatever you want here — they don’t just have to be span utilities.

To add new row-start-{n} utilities, use the gridRowStart section of your Tailwind theme config:

tailwind.config.js

  1. module.exports = {
  2. theme: {
  3. extend: {
  4. gridRowStart: {
  5. '8': '8',
  6. '9': '9',
  7. '10': '10',
  8. '11': '11',
  9. '12': '12',
  10. '13': '13',
  11. }
  12. }
  13. }
  14. }

To add new row-end-{n} utilities, use the gridRowEnd section of your Tailwind theme config:

tailwind.config.js

  1. module.exports = {
  2. theme: {
  3. extend: {
  4. gridRowEnd: {
  5. '8': '8',
  6. '9': '9',
  7. '10': '10',
  8. '11': '11',
  9. '12': '12',
  10. '13': '13',
  11. }
  12. }
  13. }
  14. }

Learn more about customizing the default theme in the theme customization documentation.

Arbitrary values

If you need to use a one-off grid-row/grid-row-start/grid-row-end value that doesn’t make sense to include in your theme, use square brackets to generate a property on the fly using any arbitrary value.

  1. <div class="row-[span_16_/_span_16]">
  2. <!-- ... -->
  3. </div>

Learn more about arbitrary value support in the arbitrary values documentation.