Fylgja does not need a framework or specific tools to work. Giving you the freedom on how to use Fylgja in project.
By default we advice the Dart Sass setup. But feel free to use the PostCSS import alternative instead. Which is almost the same as the SCSS version, in use.
This guide will focus on the Sass setup. And will show you a sample setup in a blank environment.
First make sure to install Sass. If not already done so.
npm i -D sass
Add a script that will run your Sass styles;
"start": "sass src/main.scss dist/main.css -s compressed --load-path=node_modules",
Or run it via your own preferred tool, e.g. Gulp, Webpack or Rollup.
Adding Fylgja components
This part can be done via a bundle or adding each component individual.
For this sample we are setting up a blog page. But for making this demo a little easier, we will install Fylgja as one package instead.
npm i fylgja
Loading the styles
Add the following Fylgja components to your
@use "@fylgja/theme" with (
We will also add the
@fylgja/theme component, which is part of many Fylgja component as dependency and helper for color and spacer styles.
With this we can quickly edit the theme color for all of the Fylgja components, without having to set it per Fylgja component we just imported.
Building your CSS
This last step is the simple one. Just run;
npm start # or `npm run start`
This will create a
main.css in your dist folder. Now you have a CSS file containing styles for a blog.
From here on you can extend or change many things to your liking;
- Load other SCSS file to the
main.scssor adjust Fylgja to your needs.
- You can extend the compiler logic by adding PostCSS plugins. To extend or polyfill.
- Optimize the CSS size by removing some styles your self. or by using tools, like PurgeCSS and CleanCSS.