Introduction Modules Flavors Customization Github

mini.css

v2.0

Customization

mini.css is built in such a way that customizing it is really simple. You can try out one of the pre-defined flavors, if you want to start learning and build something quickly. We strongly suggest, however, that you customize an existing flavor or build your own, by tweaking variables and using mixins, in order to create your own, unique style. In this page, we will try to give you some guidelines and tips on how to do so and explain a few more things about the inner workings of mini.css.


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 at the very bottom of _core.scss 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 core module.

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 was 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 a lot 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. To use a mixin, simply @include it, passing values to at least its mandatory parameters. We recommend you write mixins wherever possible, if you create any new modules for mini.css


Building a flavor

Creating your own flavor can be as easy or as complicated as your needs. In this section, we will briefly walk you through most of the variables usually present in a flavor, along with some flags and mixins. This section serves as a complementary documentation to the comment column present in our pre-defined flavors, instead of a replacement and should be always viewed alongside it.


Core

The core module uses a lot of variables, most of which are pretty straightforward. Some of the most important ones are as follows:

  • $fore-color - base text color
  • $back-color - base background color or image
  • $base-font-family - font stack
  • $base-root-font-size - font size of the page's root element, must be specified in px units
  • $base-line-height - base line height for the page's text
  • $body-margin - margin of the <body> element

Apart from the above variables, you should take note of the boolean $apply-defaults-to-all, which will reset font styling for all elements, utilizing the value of $base-font-size in the process. Certain elements like headings, horizontal rules and code blocks have some opinionated "modern" styles which can be turned on or off, using the boolean variables $make-heading-smalltext-block, $horizontal-rule-fancy-style and $add-pre-element-sidebar. The $style-samp-element and $include-dfn-fix boolean variables will either add styling for the elements they affect or completely omit it. This is part of the code optimization process, as most websites rarely use these elements. Finally, there are two boolean variables for link styling, $apply-link-underline and $apply-link-hover-fade.

Grid

Navigation

Input Control

Table

Card

Tab

Contextual

Progress

Utility