Introduction Modules Flavors Templates Customization Quick Reference  Github

Customization

mini.css is built in such a way that customization is really simple. You could try out one of the pre-defined flavors, if you want, in order to get used to the framework and build something quickly and easily. However, many projects require custom styles and color palettes, which is when you need to get your hands dirty and start creating your own flavor by customizing an existing one and using mixins and variables to create your own, unique style for your brand or product. This page, along with the rest of the Customization section is aimed at developers who want to tweak the code provided with mini.css to create their own flavors for their projects, as well as active maintainers of the framework and people who just want to understand the inner workings of the codebase.

Use the sidebar menu to quickly jump to the documentation of any module that you want to check out. We strongly recommend, however, that you read the general information provided below before you start exploring the modules' code, especially if you are not familiar with the way mini.css is structured.



Introduction & basics

mini.css is written using Sass, a very popular CSS preprocessor. We use Sass to do four things:

  • Make the code modular
  • Create variables that can be changed on the fly
  • Optimize the code
  • Create reusable mixins

Modules & file structure

At the heart of mini.css are modules - groups of classes and styles that aim to solve one set of needs. There are 10 modules in mini.css, which have been already written for you. All of the modules are built using partial files, named _module_name.scss and placed in the src/mini folder. You can edit any of the modules' code and/or add your own modules, following the same structure. The only thing you need to remember to do, in order to add your module to your flavor, is to add an @import statement after all the required variable declarations towards the bottom of your flavor file and it will be compiled along with the rest of mini.css. Similarly, to disable a module, just comment out its @import statement from the flavor file.


Variables

Everything in mini.css is based on Sass variables. We try to make our variable names as descriptive as possible, usually using names like $block-element-property-name, but some things might vary a little bit. Changing the values of variables should be reasonably easy, simply navigate to the src/flavors/flavor-name.scss file for a pre-defined flavor and you will see a list of variables that you can tweak. Change the values as you see fit and your finalized stylesheet will reflect the changes you have made. We did our best to make everything as customizable as possible, so that different people can build entirely different flavors using the same building blocks.


Code optimization

Building mini.css was no small task. Making it lightweight and customizable made things even harder, because these two things don't go well together most of the time. What we did was put more of the load on the preprocessor, instead of the final file. In order to accomplish this, we optimized as much of the code as possible, using conditions, flags and other tricks, so that compiling a flavor file might take one second longer, but loading won't. If you add any code to a flavor yourself, remember not only to make it customizable, but also to optimize it as best as possible.


Mixins

A lot of elements and components can be styled in many ways and most of the time we want a few styles to be available, without having to rewrite everything. We utilized the @mixin directive of Sass wherever we could to make it possible for you to easily create styles for pre-existing components and elements without having to tweak the base code for said elements or components. Each module's mixins can be found in the corresponding _module_name_mixins.scss file in the src/mini folder. To use a mixin, simply @import its file and then @include the mixin itself, passing values to at least its mandatory parameters. We recommend you write mixins wherever possible, if you create any new modules for mini.css.


To read more about the inner workings of mini.css, please choose a module from the top navigation bar to view its documentation.