Monsoon v0.2.0
Made by Alexandre Kohler Star

Getting started

Install Monsoon with npm

Installing from npm pins Monsoon in your lockfile, lets your bundler include the stylesheet in its output, and gives you the monsooncss command for purging. The package contains CSS only: there is no JavaScript to load at runtime.

3 min read

Install the package

Terminalbash
npm install monsooncss

The package has no dependencies. It contains the two stylesheets in dist/, the command line tool in bin/, the readme, the license and the changelog.

What the package exports

Import pathFileNotes
monsooncssdist/monsoon.min.cssThe default. Minified.
monsooncss/cssdist/monsoon.cssThe same rules, formatted and readable.
monsooncss/mindist/monsoon.min.cssAn explicit name for the default.
monsooncss/package.jsonpackage.jsonFor tools that read the version.

There is no JavaScript entry point. The main, style, unpkg and jsdelivr fields all point at the minified stylesheet, and sideEffects lists *.css, so bundlers that tree shake never drop the import.

The exports map is strict, so a deep path such as monsooncss/dist/monsoon.css cannot be imported through the package name. Use monsooncss/css, or point at the file on disk.

Import it in a bundler

Any bundler that handles CSS imports (Vite, webpack with a CSS loader, Parcel, esbuild) can import the stylesheet from your entry file. Import it once, before your own styles:

main.js
import 'monsooncss';
import './styles.css';

To bundle the readable file while you debug, import monsooncss/css instead. In production the minified default is the better choice.

You can also import it from a CSS file. @import must come before any other rule in the file:

styles.css
@import 'monsooncss';

:root {
  --seed: #0d9488;
}

.prose-link {
  color: var(--primary);
  text-decoration: underline;
}

The import is the same in every framework, only the entry file changes:

StackWhere the import goesGuide
React with Vitesrc/main.jsxReact
Next.js (App Router)app/layout.tsxNext.js
Vue with Vitesrc/main.jsVue
Nuxtthe css array in nuxt.config.tsNuxt
SvelteKitsrc/routes/+layout.svelteSvelteKit
Astrothe frontmatter of your layoutAstro
Angularthe styles array in angular.jsonAngular
Solid with Vitesrc/index.jsxSolid

Copy the file instead

Server rendered stacks such as Laravel, Django, Rails, WordPress or plain PHP often have no CSS bundler. Copy the stylesheet into your public folder and link it like any other static asset:

Terminalbash
cp node_modules/monsooncss/dist/monsoon.min.css public/css/monsoon.min.css

To keep the copy in sync when you update the package, run the copy from an npm script. This version uses Node instead of cp, so it also works in Windows terminals. Create the public/css folder once beforehand:

package.json
{
  "scripts": {
    "copy:css": "node -e \"require('fs').copyFileSync('node_modules/monsooncss/dist/monsoon.min.css', 'public/css/monsoon.min.css')\"",
    "postinstall": "npm run copy:css"
  },
  "devDependencies": {
    "monsooncss": "^0.2.0"
  }
}

Then link /css/monsoon.min.css from your layout. The Laravel, Django, Rails, WordPress and PHP guides show the exact template tag for each.

The monsooncss command

The package also installs a command line tool named monsooncss. It needs Node.js 18 or newer. Run it with npx, or call it by name from an npm script:

Terminalbash
npx monsooncss --version
0.2.0
CommandWhat it does
monsooncss purge <glob...> -o <file>Writes a stylesheet with only the utilities your files use. See Purge CLI.
monsooncss classesLists every utility class, variants included. Add --filter <text> or --json.
monsooncss --helpPrints usage and examples.
monsooncss --versionPrints the installed version.

Updating

npm treats versions below 1.0 carefully: a caret range such as ^0.2.0 accepts new 0.2.x patches but not the next minor release. To move to a new minor version, install it explicitly and read the changelog first:

Terminalbash
npm install monsooncss@latest

To see which version a project uses, run npm ls monsooncss or npx monsooncss --version. If you copy the file into a public folder, remember that the copy only changes when your copy script runs again.

Frequently asked questions

Should I import monsooncss or monsooncss/css?

Use monsooncss, the minified file, for production builds. monsooncss/css contains the same rules, formatted for reading and debugging.

Does it work in TypeScript projects?

Yes. The package only ships CSS, so there are no types to install. A side effect import such as import 'monsooncss' works wherever your bundler handles CSS.

Do I have to install the package to use the purge command?

No. npx monsooncss purge fetches the package on demand. Installing it as a dev dependency pins the version for your team and your CI.

No recent searches

Try , , or .

Recent

Loading the search index

No results for ""

Check the spelling, or search a class name such as px-4.