Layout
CSS utility classes for creating layouts
Source ↗️ Report Issue ↗️Webcore comes with a handful of CSS utility classes to help you build different layouts faster. To use utility classes, you must have the includeUtilities
rule set to true
in your setup
mixin. This is enabled by default. If you’d like to exclude utility classes from your CSS bundle, make sure to set this rule to false
.
Utilities comes with the following three base classes:
.container
: Sets a maximum width for the element with a default padding and auto margins..flex
: Sets thedisplay
property of the element toflex
..grid
: Sets thedisplay
property of the element togrid
.
.flex
and .grid
CSS utility classes are a work in progress, and more utility classes, including responsive classes are to be added in future releases. .container with a max-width, padding, and auto margins
Flex
When setting the .flex
class on an element, you’ll be able to use the following utility classes to change its appearance:
To set gaps, use onse of the spacing properties. The default values can be changed using the webcore.config.scss
file.
Class | Default value |
---|---|
.none | 0 |
.xxs | 2px |
.xs | 5px |
.sm | 10px |
.md | 15px |
.default | 20px |
.lg | 25px |
.xl | 30px |
.xl2 | 35px |
.xl3 | 40px |
.xl4 | 45px |
.xl5 | 50px |
2xl
, 3xl
, 4xl
, and 5xl
spacing values can be used with the .xl2
, .xl3
, .xl4
, and .xl5
classes. Direction
To change the direction of your flex items, you can use the .row
, .column
, .row-reverse
, and .column-reverse
classes:
Class | CSS |
---|---|
.row | flex-direction: row |
.column | flex-direction: column |
.row-reverse | flex-direction: row-reverse |
.column-reverse | flex-direction: column-reverse |
Alignments
To change the vertical and horizontal alignments of flex items, you can use the following CSS classes:
Class for horizontal alignment | CSS |
---|---|
.justify-start | justify-content: flex-start |
.justify-center | justify-content: center |
.justify-end | justify-content: flex-end |
.justify-between | justify-content: space-between |
.justify-around | justify-content: space-around |
.justify-evenly | justify-content: space-evenly |
Class for vertical alignment | CSS |
---|---|
.items-start | align-items: flex-start |
.items-center | align-items: center |
.items-end | align-items: flex-end |
.center
class to set both justify-content
and align-items
to center
. Wraps
To change the way flex items wrap, use the .wrap
, .nowrap
, or .wrap-reverse
classes:
Class | CSS |
---|---|
.wrap | flex-wrap: wrap |
.nowrap | flex-wrap: nowrap |
.wrap-reverse | flex-wrap: wrap-reverse |
Grid
Setting gaps and alignments for grids can be done using the same classes as shown above for .flex
elements. To change the number of grid columns on your page, you can use the following CSS classes:
Class | Layout |
---|---|
.col-2 | Two-column layout |
.col-3 | Three-column layout |
min-width: 600px: | - |
.xs-2 | Two-column layout |
.xs-3 | Three-column layout |
.xs-4 | Four-column layout |
min-width: 800px: | - |
.sm-2 | Two-columns |
.sm-3 | Three-columns |
.sm-4 | Four-columns |
min-width: 1024px: | - |
.md-2 | Two-columns |
.md-3 | Three-columns |
.md-4 | Four-columns |
.md-5 | Five-columns |
.md-6 | Six-columns |
min-width: 1200px: | - |
.lg-2 | Two-columns |
.lg-3 | Three-columns |
.lg-4 | Four-columns |
.lg-5 | Five-columns |
.lg-6 | Six-columns |
.lg-7 | Seven-columns |
.lg-8 | Eight-columns |
Request improvement for this page