The Tailwind CSS grid creates visual consistency between layouts
while allowing flexibility across a wide variety of designs.
Grid Components
Container
Containers are the most basic layout element in Notus Javascript and
are required when using our default grid system. Containers are used
to contain, pad, and (sometimes) center the content within them.
While containers can be nested, most layouts do not require a nested
container.
In some cases, where we wanted to align items we used flex-box
utility classes, for example:
Row
Rows are wrappers for columns. Each column has horizontal
padding
for controlling the space between them. This
padding is
then counteracted on the rows with negative margins. This way, all
the content in your columns is visually aligned down the left side.
Column
For the column part of the grid, we’ve used the following base
classes:
This means, that on small devices, each column will default to full
width.
And for other types of devices, you can use the
{$breakpoint}:w-{$width}
classes, where
{$breakpoint}
can be one of sm, md,
lg, and xl. And the
{$width}
can be one of:
A number from 0 to 64
A division of type
x/y,
where
x and
y can be
numbers from 1 to 12
For example:
Which means, that this column on medium width devices will take 5
out of 12 columns grid, i.e. ~
41.6% of
the screen width, and on smaller devices, will take a full width.
Breakpoints:
Anything prefixed by the
sm: will
take place for devices with a width of at least
640px
Anything prefixed by the
md: will
take place for devices with a width of at least
768px
Anything prefixed by the
lg: will
take place for devices with a width of at least
1024px
Anything prefixed by the
xl: will
take place for devices with a width of at least
1280px
Examples
Note: we’ve added some extra styles for the inner elements of the
columns so that you see the example a bit better
Equal Width
Three equal-width columns on small, medium, large, and extra large
devices using our predefined grid classes. For this, we’ve also
added the
flex-1
utility class on each of the column components.
One of three columns
One of three columns
One of three columns
Same example as the one from above, but instead of using
flex-1
class, we’ll change the
w-full one
to w-1/3,
and the effect will be the same:
One of three columns
One of three columns
One of three columns
Here are two grid layouts that apply to every device and viewport.
Add any number of unit-less classes for each breakpoint you need and
every column will be the same width.
1 of 2
2 of 2
1 of 3
2 of 3
3 of 3
Setting one column width
Auto-layout for flexbox grid columns also means you can set the
width of one column and have the sibling columns automatically
resize around it. You may use predefined grid classes (as shown
below), grid mixins, or inline widths. Note that the other columns
will resize no matter the width of the center column.
1 of 3
2 of 3 (wider)
3 of 3
1 of 3
2 of 3 (wider)
3 of 3
Variable width content
Use
{$breakpoint}:
classes to size columns based on the natural width of their content.
1 of 3
Variable width content
3 of 3
1 of 3
Variable width content
3 of 3
Equal-width multi-row
Create equal-width columns that span multiple rows by inserting a
.w-full
where you want the columns to break to a new line. Make the breaks
responsive by mixing the
.w-full
with some responsive display utilities.
column
column
column
column
Breakpoints
For grids that are the same from the smallest of devices to the
largest, use the simple column classes and
w-{$width}
classes. Specify a numbered class when you need a particularly sized
column; otherwise, feel free to stick to the simple column classes.
column
column
column
column
column of 8
column of 4
Stacked to horizontal
Using a single set of
sm:w-*
classes, you can create a basic grid system that starts out stacked
and becomes horizontal at the small breakpoint (sm).
column 8
column 4
column
column
column
Mix and match
Don’t want your columns to simply stack in some grid tiers? Use a
combination of different classes for each tier as needed. See the
example below for a better idea of how it all works.