Vanilla HTML
This guide walks through using NemCSS in a plain HTML project with no build framework. We'll use the nemcss CLI directly.
Project structure
my-project/
design-tokens/
colors.json
spacings.json
src/
styles.css
dist/
styles.css (generated)
index.html
nemcss.config.jsonStep 1: Install nemcss
sh
npm install -D nemcsssh
pnpm add -D nemcsssh
yarn add -D nemcsssh
bun add -D nemcsssh
npm install -g nemcssStep 2: Initialize nemcss
sh
npx nemcss initsh
pnpm dlx nemcss initsh
yarn dlx nemcss initsh
nemcss initThis creates nemcss.config.json and a design-tokens/ folder with example token files.
Step 3: Configure content paths
Edit nemcss.config.json to point at your HTML files:
json
{
"content": ["./*.html"],
"tokensDir": "design-tokens"
}Step 4: Add @nemcss base; to your CSS
Create src/styles.css and add the directive:
css
@nemcss base;Step 5: Link the output CSS in your HTML
html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>My project</title>
<link rel="stylesheet" href="dist/styles.css" />
</head>
<body>
<h1 class="text-default">Hello NemCSS</h1>
<p class="p-md text-muted">Styled with design tokens.</p>
</body>
</html>Step 6: Build
sh
npx nemcss build -i src/styles.css -o dist/styles.cssThe dist/styles.css file will contain the generated custom properties and only the utility classes used in your HTML.
Step 7: Watch during development
sh
npx nemcss watch -i src/styles.css -o dist/styles.cssThe output file rebuilds automatically when you change a token file, your config, or any content file.