Wijmo and Sass

Wijmo and Sass

We recently switched to Sass to make it easier to create and maintain Wijmo CSS files.

Sass improves CSS the same way TypeScript improves JavaScript. It provides modularization, variables, structure, compile time syntax checking, selector nesting, functions, and more. Over the last few years, Sass has become the most popular CSS preprocessor, being supported by all popular JavaScript frameworks and bundler tools.

Just like TypeScript, Sass is optional. You can use the CSS files we build with Sass and forget it exists. But if you want to customize the Wijmo styles, create your own themes, or create smaller CSS files that include only the Wijmo modules you use, then we suggest you use Sass.

If you run this through the Web Compiler or any other Sass tool, you will get the regular wijmo.css and wijmo.min.css output.

Smaller CSS files

If you don't use any of the Wijmo enterprise modules and would like to reduce the size of your CSS files, you could create a wijmo-core.scss file that looks like the wijmo.scss above minus the last five lines (the ones that include the enterprise modules).

This will create a wijmo-core.css file that is about half the size of the full wijmo.css.

We have done this for you already. The wijmo-core.css file is included in our distribution. But you can use this approach to generate optimized CSS files that include only the modules your application needs. For example, you could create a CSS file that contains rules only for the input and grid modules.

Custom Themes

In addition to the standard wijmo.css file, Wijmo includes many custom themes. Most themes are created by overriding the value of a few Sass variables. For example, the cerulean theme is created from the wijmo.theme.cerulean.scss file:

The theme file sets some Wijmo variables and then includes the base wijmo.scss file. That's all there is to it. The output is a wijmo.theme.cerulean.css file that can be used instead of the standard wijmo.css.

NOTE: The theme files are self-contained. They replace rather than extend the standard wijmo.css file. This is a change from previous versions of Wijmo.