Grid

The grid plugin creates component classes to easily work with a 12 columns layout.

Configuration

The plugin can be configured with the theme.gridPlugin property:

module.exports = {
  theme: {
    gridPlugin: {
      columns: 12,
      gutterWidth: 1,
      gutterUnit: 'rem',
      prefix: 'c-',
    },
  },
};


 
 
 
 
 
 


columns

  • Type: Number
  • Default: 12

The total number of columns.

gutterWidth

  • Type: [ Number, String, Object ]
  • Default: 1

The width of the grid's gutters provided as a unitless number. You can configure different widths per breakpoint by providing an object with the following schema:

{
  default: <value>,
  ...<screen>: <value,
}

The following configuration...

module.exports = {
  theme: {
    screens: {
      s: '600px',
      m: '1200px',
      l: '1800px',
    },
    gridPlugin: {
      gutterWidth: {
        default: 2,
        m: 4,
      },
    },
  },
};

...would generate a grid component with gutters of size 2 for viewports from 0 to 1200px and of size 4 for viewports from 1200px and up.

gutterUnit

  • Type: String
  • Default: 'rem'

The CSS unit used for the gutters.

prefix

  • Type: String
  • Default : ''

The prefix used by the plugin to prevent conflicts with other classes. It defaults to float-.

Classes

Container

ClassDescriptionVariants
.float-grid@todo[]
.float-grid-nested@todo[]
.float-grid-no-gutter@todo[]

Row

ClassDescriptionVariants
.float-grid-row@todoresponsive
.float-grid-row-start@todoresponsive
.float-grid-row-center@todoresponsive
.float-grid-row-end@todoresponsive
.float-grid-row-stretch@todoresponsive

Columns

ClassDescriptionVariants
.float-grid-pull-<count>@todoresponsive
.float-grid-push-<count>@todoresponsive
.float-grid-col-<count>@todoresponsive
.float-grid-col-center@todoresponsive
.float-grid-col-clear@todoresponsive
.float-grid-col-left@todoresponsive
.float-grid-col-no-clear@todoresponsive
.float-grid-col-right@todoresponsive

Examples

Simple

1
1
1
1
1
1
1
1
1
1
1
1
2
2
2
2
2
2
3
3
3
3
4
4
4
6
6
12
<div class="float-grid">
  <div class="float-grid-row mb-2">
    <div class="float-grid-col-1">
      <div class="h-4 text-grey-600 bg-white flex items-center justify-center">1</div>
    </div>
    <div class="float-grid-col-1">
      <div class="h-4 text-grey-600 bg-white flex items-center justify-center">1</div>
    </div>
    <div class="float-grid-col-1">
      <div class="h-4 text-grey-600 bg-white flex items-center justify-center">1</div>
    </div>
    <div class="float-grid-col-1">
      <div class="h-4 text-grey-600 bg-white flex items-center justify-center">1</div>
    </div>
    <div class="float-grid-col-1">
      <div class="h-4 text-grey-600 bg-white flex items-center justify-center">1</div>
    </div>
    <div class="float-grid-col-1">
      <div class="h-4 text-grey-600 bg-white flex items-center justify-center">1</div>
    </div>
    <div class="float-grid-col-1">
      <div class="h-4 text-grey-600 bg-white flex items-center justify-center">1</div>
    </div>
    <div class="float-grid-col-1">
      <div class="h-4 text-grey-600 bg-white flex items-center justify-center">1</div>
    </div>
    <div class="float-grid-col-1">
      <div class="h-4 text-grey-600 bg-white flex items-center justify-center">1</div>
    </div>
    <div class="float-grid-col-1">
      <div class="h-4 text-grey-600 bg-white flex items-center justify-center">1</div>
    </div>
    <div class="float-grid-col-1">
      <div class="h-4 text-grey-600 bg-white flex items-center justify-center">1</div>
    </div>
    <div class="float-grid-col-1">
      <div class="h-4 text-grey-600 bg-white flex items-center justify-center">1</div>
    </div>
  </div>
  <div class="float-grid-row mb-2">
    <div class="float-grid-col-2">
      <div class="h-4 text-grey-600 bg-white flex items-center justify-center">2</div>
    </div>
    <div class="float-grid-col-2">
      <div class="h-4 text-grey-600 bg-white flex items-center justify-center">2</div>
    </div>
    <div class="float-grid-col-2">
      <div class="h-4 text-grey-600 bg-white flex items-center justify-center">2</div>
    </div>
    <div class="float-grid-col-2">
      <div class="h-4 text-grey-600 bg-white flex items-center justify-center">2</div>
    </div>
    <div class="float-grid-col-2">
      <div class="h-4 text-grey-600 bg-white flex items-center justify-center">2</div>
    </div>
    <div class="float-grid-col-2">
      <div class="h-4 text-grey-600 bg-white flex items-center justify-center">2</div>
    </div>
  </div>
  <div class="float-grid-row mb-2">
    <div class="float-grid-col-3">
      <div class="h-4 text-grey-600 bg-white flex items-center justify-center">3</div>
    </div>
    <div class="float-grid-col-3">
      <div class="h-4 text-grey-600 bg-white flex items-center justify-center">3</div>
    </div>
    <div class="float-grid-col-3">
      <div class="h-4 text-grey-600 bg-white flex items-center justify-center">3</div>
    </div>
    <div class="float-grid-col-3">
      <div class="h-4 text-grey-600 bg-white flex items-center justify-center">3</div>
    </div>
  </div>
  <div class="float-grid-row mb-2">
    <div class="float-grid-col-4">
      <div class="h-4 text-grey-600 bg-white flex items-center justify-center">4</div>
    </div>
    <div class="float-grid-col-4">
      <div class="h-4 text-grey-600 bg-white flex items-center justify-center">4</div>
    </div>
    <div class="float-grid-col-4">
      <div class="h-4 text-grey-600 bg-white flex items-center justify-center">4</div>
    </div>
  </div>
  <div class="float-grid-row mb-2">
    <div class="float-grid-col-6">
      <div class="h-4 text-grey-600 bg-white flex items-center justify-center">6</div>
    </div>
    <div class="float-grid-col-6">
      <div class="h-4 text-grey-600 bg-white flex items-center justify-center">6</div>
    </div>
  </div>
  <div class="float-grid-row mb-2">
    <div class="float-grid-col-12">
      <div class="h-4 text-grey-600 bg-white flex items-center justify-center">12</div>
    </div>
  </div>
</div>

No gutter

1
1
1
1
1
1
1
1
1
1
1
1
2
2
2
2
2
2
3
3
3
3
4
4
4
6
6
12
<div class="float-grid float-grid-no-gutter">
  ...
</div>

Nested

1
1
1
1
1
1
1
1
1
1
1
1
2
2
2
2
2
2
3
3
3
3
4
4
4
6
6
12
<div class="float-grid float-grid-nested">
  ...
</div>

Tailwind only equivalent

The grid plugin can be replaced with Tailwind utility classes for expert users:

Using grid

Tailwind using grid

1
1
1
1
1
1
1
1
1
1
1
1

Grid plugin

1
1
1
1
1
1
1
1
1
1
1
1
<div class="px-2 s:px-4 l:px-6 xxl:px-8">
    <div class="grid grid-cols-12 gap-4 s:gap-8 l:gap-12 xxl:gap-16">
      <div>1</div>
      <div>1</div>
      <div>1</div>
      <div>1</div>
      <div>1</div>
      <div>1</div>
      <div>1</div>
      <div>1</div>
      <div>1</div>
      <div>1</div>
      <div>1</div>
      <div>1</div>
    </div>
  </div>

Using float

Tailwind using float

1
1
1
1
1
1
1
1
1
1
1
1

Grid plugin

1
1
1
1
1
1
1
1
1
1
1
1
<div class="px-2 s:px-4 l:px-6 xxl:px-8">
  <div class="clearfix -mx-2 s:-mx-4 l:-mx-6 xxl:-mx-8">
    <div class="w-1/12 float-left px-2 s:px-4 l:px-6 xxl:px-8">
      <div class="h-4 text-grey-600 bg-white flex items-center justify-center">1</div>
    </div>
    <div class="w-1/12 float-left px-2 s:px-4 l:px-6 xxl:px-8">
      <div class="h-4 text-grey-600 bg-white flex items-center justify-center">1</div>
    </div>
    <div class="w-1/12 float-left px-2 s:px-4 l:px-6 xxl:px-8">
      <div class="h-4 text-grey-600 bg-white flex items-center justify-center">1</div>
    </div>
    <div class="w-1/12 float-left px-2 s:px-4 l:px-6 xxl:px-8">
      <div class="h-4 text-grey-600 bg-white flex items-center justify-center">1</div>
    </div>
    <div class="w-1/12 float-left px-2 s:px-4 l:px-6 xxl:px-8">
      <div class="h-4 text-grey-600 bg-white flex items-center justify-center">1</div>
    </div>
    <div class="w-1/12 float-left px-2 s:px-4 l:px-6 xxl:px-8">
      <div class="h-4 text-grey-600 bg-white flex items-center justify-center">1</div>
    </div>
    <div class="w-1/12 float-left px-2 s:px-4 l:px-6 xxl:px-8">
      <div class="h-4 text-grey-600 bg-white flex items-center justify-center">1</div>
    </div>
    <div class="w-1/12 float-left px-2 s:px-4 l:px-6 xxl:px-8">
      <div class="h-4 text-grey-600 bg-white flex items-center justify-center">1</div>
    </div>
    <div class="w-1/12 float-left px-2 s:px-4 l:px-6 xxl:px-8">
      <div class="h-4 text-grey-600 bg-white flex items-center justify-center">1</div>
    </div>
    <div class="w-1/12 float-left px-2 s:px-4 l:px-6 xxl:px-8">
      <div class="h-4 text-grey-600 bg-white flex items-center justify-center">1</div>
    </div>
    <div class="w-1/12 float-left px-2 s:px-4 l:px-6 xxl:px-8">
      <div class="h-4 text-grey-600 bg-white flex items-center justify-center">1</div>
    </div>
    <div class="w-1/12 float-left px-2 s:px-4 l:px-6 xxl:px-8">
      <div class="h-4 text-grey-600 bg-white flex items-center justify-center">1</div>
    </div>
  </div>
</div>
Last Updated:
Contributors: Antoine Quatrelivre, Titouan Mathis