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.
Install the package
npm install monsooncsspnpm add monsooncssyarn add monsooncssbun add monsooncssThe 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 path | File | Notes |
|---|---|---|
monsooncss | dist/monsoon.min.css | The default. Minified. |
monsooncss/css | dist/monsoon.css | The same rules, formatted and readable. |
monsooncss/min | dist/monsoon.min.css | An explicit name for the default. |
monsooncss/package.json | package.json | For 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:
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:
@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:
| Stack | Where the import goes | Guide |
|---|---|---|
| React with Vite | src/main.jsx | React |
| Next.js (App Router) | app/layout.tsx | Next.js |
| Vue with Vite | src/main.js | Vue |
| Nuxt | the css array in nuxt.config.ts | Nuxt |
| SvelteKit | src/routes/+layout.svelte | SvelteKit |
| Astro | the frontmatter of your layout | Astro |
| Angular | the styles array in angular.json | Angular |
| Solid with Vite | src/index.jsx | Solid |
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:
cp node_modules/monsooncss/dist/monsoon.min.css public/css/monsoon.min.cssTo 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:
{
"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:
npx monsooncss --version0.2.0| Command | What it does |
|---|---|
monsooncss purge <glob...> -o <file> | Writes a stylesheet with only the utilities your files use. See Purge CLI. |
monsooncss classes | Lists every utility class, variants included. Add --filter <text> or --json. |
monsooncss --help | Prints usage and examples. |
monsooncss --version | Prints 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:
npm install monsooncss@latestTo 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.