Logo
AndreaDSW
BETA

CSS Framework or CSS Preprocessor

Last Modified:

Exploring the differences between CSS frameworks and preprocessors, and when to use each for efficient web development.

Bootstrap CSS Framework

I am still working with Bootstrap on some legacy websites. In the past, Bootstrap was really popular because it gave ready pre-designed components right out of the box.

Bootstrap has components ready to use. For instance, a button is designed with colours, hover effects, and sizing options, as well as components like forms, modals, cards, and drop-down menus. Building websites is easy because the standardised components.

However, Bootstrap's default components are pre-styled. If you want to avoid creating websites with the same Bootstrap look, the way is to override its default classes. Any customisation needs to be done in order to differentiate Bootstrap from the default components. This is where things start to be very time-consuming and sometimes messy.

Although Bootstrap provides a reliable grid system that automatically adjusts to screen sizes and is consistent. There are limited built-in accessibility requirements, making developers add them separately in the code.

Bootstrap still offers professional-looking designs that work across all browsers; however, it has limitations if you want to build more scalable websites. More about Bootstrap here is the documentation https://getbootstrap.com/ (opens in a new tab)

Stylable CSS Preprocessor

Stylable is an open-source CSS preprocessor developed by Wix. One of the main benefits is to offer a modular component-scoped approach to build websites with scalability and reusability. It makes it possible to reuse components across large teams. What does 'component-scoped' mean? You can style your component according to its own scope. Another advantage of using Stylable is that developers can reuse the styled component @st-scope with different themes.

For example, the Drop component:

1. Import the basic styled component drop.st.css inside Drop.tsx the component file.

CSS
:import {  -st-from: "../../../components/Drop/drop.st.css";  -st-default: Drop;}

2. Styling the class which belongs to the basic component Drop.tsx. It’s important to notice that the right format is ComponentName::ClassComponent (two semicolons).

CSS
Drop::closeIcon {  position: absolute;  clip: rect(0 0 0 0);  font-size: 0;  color: transparent;}.desktopFiltersView Drop::closeIcon {  position: absolute;  clip: rect(0 0 0 0);  font-size: 0;  color: transparent;}

Stylable converts its own filesst.css into static vanilla CSS files at build time. Components exposes an API that’s usable by its parent components. As an example, Stylable creates custom pseudo-classes through className attributes within any HTML element.

Stylable is a typed safety which allows you to have static typing, where it shows errors at build time, not in runtime. Beyond that, Stytable gave our team the flexibility to create different themes with reusing the base styled component.