Malva is a configurable, smart and fast CSS, SCSS, Sass and Less formatter.
Malva is configurable. It provides several configuration options so you can control the code style as you want.
Given the example below:
button.disabled, button:disabled {}
This selector is short enough to be put on single line, so Malva will put it on a single line by default, instead of forcing it to be splitted into multiple lines.
However, if you prefer putting into multiple lines, you can configure it.
Given the example below:
button.disabled/*please use pseudo class as possible*/,button:disabled {}
There're comments inside selector. Some formatters will fail to format it, but Malva will format as:
button.disabled /*please use pseudo class as possible*/, button:disabled {}
Also, thanks to the Raffia parser,
Malva supports cutting edge CSS syntaxes like @container
.
Malva supports indentation-based Sass, not just SCSS.
If you just want a quick try, you can try with the online playground.
We've provided dprint integration.
Run the command below to add plugin:
dprint config add g-plane/malva
After adding the dprint plugin, update your dprint.json
and add configuration:
{
// ...
"plugins": [
"https://plugins.dprint.dev/g-plane/malva-v0.9.1.wasm"
],
"malva": {
// Malva config comes here
}
}
You can also read dprint CLI documentation for using dprint to format files.
Please refer to Configuration.
Malva is not opinionated and is configurable, and we accept different code styles then switch them with configuration. But before proposing a code style change, it's better to open a new issue or discussion.
If you're using dprint, you can use markup_fmt which provides a dprint plugin, then you can use these two plugins together.
Tests come from Prettier.
MIT License
Copyright (c) 2023-present Pig Fang