Front-end boilerplate / ITCSS Architecture / CSS Utilities
Gulp / Webpack / Babel / Live Reload / Twig.js
Based on best pieces from Bootstrap, Tailwind CSS and years of experience.
Settings
ITCSS: Inverted Triangle CSS
**************** 1. Settings (start your work here)
************** 2. Tools
************ 3. Generic
********** 4. Elements
******** 5. Objects
****** 6. Components
**** 7. Modules (most work will be done here)
** 8. Utilities
1. Settings
Global configuration and variables.
Breakpoints, colors, spacing, utilities etc.
2. Tools
Functions and mixins.
3. Generic
Ground zero styles. No classes.
4. Elements
Unclassed (bare) HTML element.
H1, Ul, A etc.
5. Objects
Common non-cosmetic structural design patterns.
Containers, rows, grids, colums etc.
6. Components
Specific cosmetic elements of UI.
Buttons, forms etc.
7. Modules
Multi-part components.
Navbar, footer etc.
8. Utilities
Helpers and overrides.
Shame
All the CSS, hacks and things we are not proud of.
Define media query breakpoints.
$grid-breakpoints: (
xs: 0,
sm: 576px,
md: 768px,
lg: 992px,
xl: 1200px,
xxl: 1680px
) !default;
Define the maximum width of .container for different breakpoints.
$container-max-widths: (
sm: 540px,
md: 720px,
lg: 960px,
xl: 1140px,
xxl: 1440px
) !default;
Responsive breakpoints. {screen}: utility name
<div class="w-full sm:w-1/2 md:w-1/3 lg:w-1/4 xl:w-1/5 xxl:w-1/6"></div>
CSS media queries mixins
@include media-breakpoint-up(sm) {}
@include media-breakpoint-up(md) {}
@include media-breakpoint-up(lg) {}
@include media-breakpoint-up(xl) {}
@include media-breakpoint-up(xxl) {}
@include media-breakpoint-down(xs) {}
@include media-breakpoint-down(sm) {}
@include media-breakpoint-down(md) {}
@include media-breakpoint-down(lg) {}
@include media-breakpoint-down(xxl) {}
@include media-breakpoint-only(xs) {}
@include media-breakpoint-only(sm) {}
@include media-breakpoint-only(md) {}
@include media-breakpoint-only(lg) {}
@include media-breakpoint-only(xl) {}
@include media-breakpoint-only(xxl) {}
@include media-breakpoint-between(md, xl) {}
// Colors
$color-base: #4a5568 !default;
$color-primary: #007bff !default;
$text-secondary: #7f19e6 !default;
$color-white: #fff !default;
$color-light: #f2f2f2 !default;
$color-dark: #343a40 !default;
$color-black: #000 !default;
$color-success: #00b300 !default;
$color-error: #c00 !default;
// Map used for generating CSS utility classes
$colors: (
'base': $color-base,
'primary': $color-primary,
'secondary': $text-secondary,
'white': $color-white,
"light": $color-light,
"dark": $color-dark,
'black': $color-black,
'success': $color-success,
'error': $color-error
) !default;
// Links
$color-link-color: #007bff !default;
$color-link-color-hover: darken($color-link-color, 20%) !default;
// Used for generating margin/padding CSS utility classes
$spacer: 1rem !default;
$spacers: (
0: 0,
1: $spacer * .25,
2: $spacer * .5,
3: $spacer * .75,
4: $spacer * 1,
5: $spacer * 1.25,
6: $spacer * 1.5,
8: $spacer * 2,
12: $spacer * 3
auto: auto,
) !default;
// Font Family
$font-family-base: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji" !default;
$font-family-serif: Georgia, Cambria, "Times New Roman", Times, serif !default;
$font-family-mono: Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace !default;
$font-family-headings: $font-family-base;
// Font Size
$font-size-xs: .75rem !default;
$font-size-sm: .875rem !default;
$font-size-base: .875rem !default;
$font-size-lg: 1.125rem !default;
$font-size-xl: 1.25rem !default;
// Font Weight
$font-weight-hairline: 100 !default;
$font-weight-thin: 200 !default;
$font-weight-light: 300 !default;
$font-weight-normal: 400 !default;
$font-weight-medium: 500 !default;
$font-weight-semibold: 600 !default;
$font-weight-bold: 700 !default;
$font-weight-extrabold: 800 !default;
$font-weight-black: 900 !default;
// Line Height
$line-height-none: 1 !default;
$line-height-xs: 1.25 !default;
$line-height-sm: 1.375 !default;
$line-height-base: 1.5 !default;
$line-height-lg: 1.625 !default;
$line-height-xl: 2 !default;
// Headings
$headings-margin-bottom: 1rem !default;
$headings-font-family: $font-family-headings !default;
$headings-font-weight: $font-weight-medium !default;
$headings-letter-spacing: normal !default;
$headings-line-height: 1.2 !default;
$headings-color: inherit !default;
$headings-text-transform: inherit !default;
// Headings Responsive Size
$h1-font-size: ( xs: 20px, sm: 24px, md: 28px, lg: 32px, xl: 36px, xxl: 40px );
$h2-font-size: ( xs: 18px, sm: 20px, md: 24px, lg: 28px, xl: 32px, xxl: 36px );
$h3-font-size: ( xs: 16px, sm: 18px, md: 20px, lg: 24px, xl: 28px, xxl: 32px );
$h4-font-size: ( xs: 16px, sm: 16px, md: 18px, lg: 22px, xl: 26px, xxl: 30px );
$h5-font-size: ( xs: 16px, sm: 16px, md: 18px, lg: 20px, xl: 22px, xxl: 24px );
$h6-font-size: ( xs: 16px, sm: 16px, md: 16px, lg: 18px, xl: 20px, xxl: 20px );
// List
$list-margin-bottom: 1rem !default;
// Paragraph
$paragraph-margin-bottom: 1rem !default;
Customize responsiveness (true by default), attributes, classes etc.
You can reduce file size by removing unused breakpoints
or disabling unused utilities.
Controlling file size:
File size comparison:
Tip: you can significantly reduce the file size when you disable responsiveness of margin/padding utility classes.
Backgrounds
.bg-base | #4a5568 | |
.bg-primary | #007bff | |
.bg-secondary | #7f19e6 | |
.bg-white | #fff | |
.bg-light | #f8f9fa | |
.bg-dark | #343a40 | |
.bg-black | #000 | |
.bg-success | #00b300 | |
.bg-error | #c00 |
.bg-auto | background-size: auto; |
.bg-cover | background-size: cover; |
.bg-contain | background-size: contain; |
Layout
.container .container-fluid |
width: 100%;
margin-left: auto; margin-right: auto; |
.container | sm: max-width: 540px; |
md: max-width: 720px; | |
lg: max-width: 960px; | |
xl: max-width: 1140px; | |
xxl: max-width: 1440px; |
.block | display: block; |
.inline-block | display: inline-block; |
.inline | display: inline; |
.flex | display: flex; |
.inline-flex | display: inline-flex; |
.table | display: table; |
.table-row | display: table-row; |
.table-cell | display: table-cell; |
.hidden | display: none; |
.static | position: static; |
.fixed | position: fixed; |
.absolute | position: absolute; |
.relative | position: relative; |
.sticky | position: sticky; |
.top-0 | top: auto; |
.right-0 | right: 0; |
.bottom-0 | bottom: 0; |
.left-0 | left: 0; |
.top-auto | top: auto; |
.right-auto | right: auto; |
.bottom-auto | bottom: auto; |
.left-auto | left: auto; |
.w-1/2 | width: 50%; |
.w-1/3 | width: 33.333333%; |
.w-2/3 | width: 66.666667%; |
.w-1/4 | width: 25%; |
.w-2/4 | width: 50%; |
.w-3/4 | width: 75%; |
.w-1/5 | width: 20%; |
.w-2/5 | width: 40%; |
.w-3/5 | width: 60%; |
.w-4/5 | width: 80%; |
.w-1/6 | width: 16.666667%; |
.w-2/6 | width: 33.333333%; |
.w-3/6 | width: 50%; |
.w-4/6 | width: 66.666667%; |
.w-5/6 | width: 83.333333%; |
Typography
.text-base | #4a5568 | |
.text-primary | #007bff | |
.text-secondary | #7f19e6 | |
.text-white | #fff | |
.text-light | #f8f9fa | |
.text-dark | #343a40 | |
.text-black | #000 | |
.text-success | #00b300 | |
.text-error | #c00 |
.font-family-base | font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; |
.font-family-serif | font-family: Georgia, Cambria, "Times New Roman", Times, serif; |
.font-family-mono | font-family: Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; |
.font-family-headings | = .font-family-base |
.font-size-xs | font-size: .75rem; |
.font-size-sm | font-size: .875rem; |
.font-size-base | font-size: 1rem; |
.font-size-lg | font-size: 1.125rem; |
.font-size-xl | font-size: 1.25rem; |
.italic | font-style: italic; |
.non-italic | font-style: normal; |
.font-weight-hairline | font-weight: 100; |
.font-weight-thin | font-weight: 200; |
.font-weight-light | font-weight: 300; |
.font-weight: normal | font-weight: 400; |
.font-weight-medium | font-weight: 500; |
.font-weight-semibold | font-weight: 600; |
.font-weight-bold | font-weight: 700; |
.font-weight-extrabold | font-weight: 800; |
.font-weight-black | font-weight: 900; |
.line-height-xs | line-height: 1rem; |
.line-height-sm | line-height: 1.25rem; |
.line-height-base | line-height: 1.375rem; |
.line-height-lg | line-height: 1.5rem; |
.line-height-xl | line-height: 2rem; |
.list-none | list-style-type: none; |
.list-disc | list-style-type: disc; |
.list-decimal | list-style-type: decimal; |
.list-inside | list-style-position: inside; |
.list-outside | list-style-position: outside; |
.text-left | text-align: left; |
.text-center | text-align: center; |
.text-right | text-align: right; |
.text-justify | text-align: justify; |
.underline | text-decoration: underline; |
.line-through | text-decoration: line-through; |
.no-underline | text-decoration: none; |
.uppercase | text-transform: uppercase; |
.lowercase | text-transform: lowercase; |
.capitalize | text-transform: capitalize; |
.normal-case | text-transform: none; |
Flexbox
.content-start | align-content: flex-start; |
.content-center | align-content: center; |
.content-end | align-content: flex-end; |
.content-between | align-content: space-between; |
.content-around | align-content: space-around; |
.items-stretch | align-items: stretch; |
.items-start | align-items: stretch; |
.items-center | align-items: center; |
.items-end | align-items: flex-end; |
.items-baseline | align-items: baseline; |
.self-auto | align-self: auto; |
.self-start | align-self: flex-start; |
.self-center | align-self: center; |
.self-end | align-self: flex-end; |
.self-stretch | align-self: stretch; |
.flex-initial | flex: 0 1 auto; |
.flex-1 | flex: 1 1 0%; |
.flex-auto | flex: 1 1 auto; |
.flex-none | flex: none; |
.flex-row | flex-direction: row; |
.flex-row-reverse | flex-direction: row-reverse; |
.flex-col | flex-direction: column; |
.flex-col-reverse | flex-direction: column-reverse; |
.flex-grow | flex-grow: 1; |
.flex-grow-0 | flex-grow: 0; |
.flex-shrink | flex-shrink: 1; |
.flex-shrink-0 | flex-shrink: 0; |
.flex-no-wrap | flex-wrap: nowrap; |
.flex-wrap | flex-wrap: wrap; |
.flex-wrap-reverse | flex-wrap: wrap-reverse; |
.justify-start | justify-content: flex-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; |
.order-first | order: -9999; |
.order-last | order: 9999; |
.order-none | order: 0; |
.order-1 | order: 1; |
.order-2 | order: 2; |
.order-3 | order: 3; |
.order-4 | order: 4; |
.order-5 | order: 5; |
Spacing
Utilities for controlling an element's padding and margin.
.{property}{side}-{size}
.{screen}:{property}{side}-{size}
Property
p
padding
m
margin
Side
all
t
top
r
right
b
bottom
l
left
x
horizontal
y
vertical
Space
0
0
1
.25rem
2
.5rem
3
.75rem
4
1rem
5
1.25rem
6
1.5rem
8
2rem
12
3rem
auto
auto (margins only)
Negative margins start with -m{side?}-{size}
e.g. -mx-2 or -mt-8
.m-0 | margin: 0; |
.m-1 | margin: 0.25rem; |
.m-2 | margin: 0.5rem; |
.m-3 | margin: 0.75rem; |
.m-4 | margin: 1rem; |
.m-5 | margin: 1.25rem; |
.m-6 | margin: 1.5rem; |
.m-8 | margin: 2rem; |
.m-12 | margin: 3rem; |
.my-0 |
margin-top: 0; margin-bottom: 0; |
... | |
.my-12 |
margin-top: 3rem; margin-bottom: 3rem; |
.mx-0 |
margin-left: 0; margin-right: 0; |
... | |
.mx-12 |
margin-left: 3rem; margin-right: 3rem; |
.mt-0 | margin-top: 0; |
... | |
.mt-12 | margin-top: 3rem; |
.mr-0 | margin-right: 0; |
... | |
.mr-12 | margin-right: 3rem; |
.mb-0 | margin-bottom: 0; |
... | |
.mb-12 | margin-bottom: 3rem; |
.ml-0 | margin-left: 0; |
... | |
.ml-12 | margin-left: 3rem; |
.m-auto | margin: auto; |
.mx-auto |
margin-left: auto; margin-right: auto; |
.my-auto |
margin-top: auto; margin-bottom: auto; |
.mt-auto | margin-top: auto; |
.mr-auto | margin-right: auto; |
.mb-auto | margin-bottom: auto; |
.ml-auto | margin-left: auto; |
.p-0 | padding: 0; |
.p-1 | padding: 0.25rem; |
.p-2 | padding: 0.5rem; |
.p-3 | padding: 0.75rem; |
.p-4 | padding: 1rem; |
.p-5 | padding: 1.25rem; |
.p-6 | padding: 1.5rem; |
.p-8 | padding: 2rem; |
.p-12 | padding: 3rem; |
.py-0 |
padding-top: 0; padding-bottom: 0; |
... | |
.py-12 |
padding-top: 3rem; padding-bottom: 3rem; |
.px-0 |
padding-left: 0; padding-right: 0; |
... | |
.px-12 |
padding-left: 3rem; padding-right: 3rem; |
.pt-0 | padding-top: 0; |
... | |
.pt-12 | padding-top: 3rem; |
.pr-0 | padding-right: 0; |
... | |
.pr-12 | padding-right: 3rem; |
.pb-0 | padding-bottom: 0; |
... | |
.pb-12 | padding-bottom: 3rem; |
.pl-0 | padding-left: 0; |
... | |
.pl-12 | padding-left: 3rem; |
Mixins
$body-font-size: (
xs: 10px,
sm: 14px,
md: 18px,
lg: 22px,
xl: 26px,
xxl: 30px
);
$body-padding-top: (
xs: 10px,
sm: 20px,
md: 30px,
lg: 40px,
xl: 50px,
xxl: 60px
);
body {
@include make-responsive(font-size, $body-font-size);
@include make-responsive(padding-top, $body-padding-top);
}
.ratio-3-4 | <div class="ratio-3-4" style="background-image: url('...')"></div> |
.ratio-4-3 | <div class="ratio-4-3" style="background-image: url('...')"></div> |
.ratio-16-9 | <div class="ratio-16-9" style="background-image: url('...')"></div> |
Components
<div class="flex flex-wrap -mx-2">
<div class="w-full md:w-1/3 px-2">
<div class="bg-light p-2">1</div>
</div>
<div class="w-full md:w-1/3 px-2">
<div class="bg-light p-2">2</div>
</div>
<div class="w-full md:w-1/3 px-2">
<div class="bg-light p-2">3</div>
</div>
</div>
<ul class="list-none m-0 p-0">
<li>Item 1</li>
<li>Item 2</li>
</ul>