Configuring Modules
Every module in Pollen can be customised, overwritten, and extended. A module is a collection of CSS variables with the same prefix, eg: scale (see Typography), size (see Layout), etc.

Enabling and disabling

Enable and disable whole module by passing true or false to the module in your config. All modules are enabled by default, set any you don't plan on using to false to further save on bundle size.
pollen.config.js
1
module.exports = {
2
modules: {
3
scale: false,
4
width: false,
5
color: true
6
}
7
}
Copied!

Overwriting

To overwrite a module, provide an object with all the values you want to use to the module in your config.
pollen.config.js
1
module.exports = {
2
modules: {
3
scale: { /* custom type scale */ },
4
letter: { /* custom letter spacing scale * }
5
}
6
}
Copied!

Extending

Often you'll want to just add or tweak a few values from Pollen's defaults instead of disabling or overwriting outright.
To do this Pollen provides all of its defaults as an argument to a configuration function rather than a plain object. Spread the appropriate key into a new object on the module to extend or overwrite Pollen's defaults.
pollen.config.js
1
module.exports = (pollen) => ({
2
modules: {
3
scale: { ...pollen.scale, '000': '0.6875rem' },
4
letter: {...pollen.letter, xxl: '0.1em' }
5
}
6
});
Copied!
These defaults are also provided in the defineConfig typescript helper
1
const { defineConfig } = require('pollen-css/utils');
2
3
module.exports = defineConfig(pollen => ({
4
modules: {
5
scale: { ...pollen.scale, '000': '0.6875rem' },
6
letter: {...pollen.letter, xxl: '0.1em' }
7
}
8
})
9
);
Copied!
Copy link
Edit on GitHub