Skip to main content

CSS Classes

A set of built-in CSS classes is available out of the box, to let you design any layout in seconds.


Concept

Built-in CSS classes are a great way to build and prototype your site/application's pages, without writing a single line of CSS. They are meant to fulfill the most common use cases, especially handling responsive in no time. You can apply any of the class below to any element of your pages. It will automatically apply the related CSS properties. If you need to apply a class only from a specific breakpoint, you can prefix any of them by that breakpoint, followed by :. These classes are mobile-first, which means that styling for the smallest breakpoint (xxs) will be considered as the default styling.

Let's take an example:

<div class="grid cols-1 m:cols-3 xl:cols-12">
<div class="col-5"/>
<div />
</div>

In this example, the layout will behave as follow:

  • For mobile / small devices (xxs and xs), it will be displayed as a one-column wide grid (each child will be placed in a new row)
  • From tablets to larger screens (between m and xl), the number of columns per row will grow up to 3. But this won't change the layout, as the first child is set to take at least 5 columns wide.
  • For larger screens (from xl), the grid will be 12-columns wide. This time, the layout will change, as the first child will take 5 columns on the first row, and the second child only one.

What's wrong with TailwindCSS?

You may wonder why we implemented yet another styling library instead of relying on libraries like TailwindCSS. Fundamentally, Tailwind is great. The concept of designing and prototyping your pages directly inside the HTML without needing to write a single line of CSS is a huge productivity booster. And by the way, you will probably notice big similitude between Tailwind classes and the ones we use.

However, at some point, allowing developers to write dozens of rules directly inside the HTML code can quickly lead to a CSS-in-HTML hell:

<main class="py-6 px-4 sm:p-6 md:py-10 md:px-8">
<div class="max-w-4xl mx-auto grid grid-cols-1 lg:max-w-5xl lg:gap-x-20 lg:grid-cols-2">
<div class="relative p-3 col-start-1 row-start-1 flex flex-col-reverse rounded-lg bg-gradient-to-t from-black/75 via-black/0 sm:bg-none sm:row-start-2 sm:p-0 lg:row-start-1">
<h1 class="mt-1 text-lg font-semibold text-white sm:text-slate-900 md:text-2xl dark:sm:text-white">Beach House in Collingwood</h1>
<p class="text-sm leading-4 font-medium text-white sm:text-slate-500 dark:sm:text-slate-400">Entire house</p>
</div>
<div class="grid gap-4 col-start-1 col-end-3 row-start-1 sm:mb-6 sm:grid-cols-4 lg:gap-6 lg:col-start-2 lg:row-end-6 lg:row-span-6 lg:mb-0">
<img src="/beach-house.jpg" alt="" class="w-full h-60 object-cover rounded-lg sm:h-52 sm:col-span-2 lg:col-span-full" loading="lazy">
<img src="/beach-house-interior-1.jpg" alt="" class="hidden w-full h-52 object-cover rounded-lg sm:block sm:col-span-2 md:col-span-1 lg:row-start-2 lg:col-span-2 lg:h-32" loading="lazy">
<img src="/beach-house-interior-2.jpg" alt="" class="hidden w-full h-52 object-cover rounded-lg md:block lg:row-start-2 lg:col-span-2 lg:h-32" loading="lazy">
</div>
</div>
</main>

The code gets ugly, looses legibility, mixes logic and style, and generates a huge redundancy, bloating the final CSS bundle. With such practice, it gets very hard to build and keep a design system consistent and clean across a project as it grows over time.

The main problem here is that Tailwind allows all CSS properties to be written in HTML. We believe that only a few subset of commonly used rules should be available, only for layout purposes. All the rest (colors, fonts, and such) should still reside in our good old SASS files, providing a complete separation of concerns.


Available classes

Built-in classCorresponding CSS
flexdisplay: flex;
griddisplay: grid;
nonedisplay: none;
blockdisplay: block;
flex-wrapflex-wrap: wrap;
flex-nowrapflex-wrap: nowrap;
flex-wrap-revflex-wrap: wrap-reverse;
flex-rowflex-direction: row;
flex-colflex-direction: column;
flex-col-revflex-direction: column-reverse;
flex-row-revflex-direction: row-reverse;
grid-rowgrid-auto-flow: row;
grid-colgrid-auto-flow: column;
grid-densegrid-auto-flow: dense;
flex-noneflex: none;
flex-autoflex: 1 1 auto;
justify-betweenjustify-content: space-between;
justify-startjustify-content: flex-start;
justify-endjustify-content: flex-end;
justify-stretchjustify-content: stretch;
justify-centerjustify-content: center;
items-centeralign-items: center;
items-startalign-items: flex-start;
items-endalign-items: flex-end;
items-stretchalign-items: stretch;
self-centeralign-self: center;
self-startalign-self: flex-start;
self-endalign-self: flex-end;
self-stretchalign-self: stretch;
cols-{1..12}grid-template-columns: repeat(1..12, 1fr);
col-{1..12}grid-column: span 1..12;
vgap-{1..7}row-gap: var(--gaps-{1..7});
hgap-{1..7}column-gap: var(--gaps-{1..7});
text-lefttext-align: left;
text-righttext-align: right;
text-centertext-align: center;
text-justifytext-align: justify;
w-fullwidth: 100%;
h-fullheight: 100%;