Installation

Set up Master CSS in Vite

Guide to setting up Master CSS in your Vite project.

Master CSS Runtime Rendering observes changes in DOM class names at browser runtime, generates corresponding CSS rules, and injects them into the running style sheet.

Fixed style cost

All features work out of the box with ~16KB transfer cost

Fully automatic

Capture any program-generated class names

CSS lifecycle

CSS is generated on demand and frees memory when not in use


Quick start

Clone the example

Copy-paste the following commands to quickly start using the vite.rr.beta.css.master.co.

You can skip all installation steps.

npx degit master-co/css/examples/vite-with-runtime-rendering my-project
cd my-project
npm install @master/css@beta
npm install
npm run dev

Installation

Create a project

If you don't have a Vite project, create one first. It's recommended to refer to Getting Started - Vite

npm create vite@latest project -- --template vanilla-ts
cd project
npm install

Install Master CSS

Install Master CSS into your project via package managers.

npm install @master/css@beta

Initialize configuration file

Run npx mcss init to create a configuration file master.css.ts.

npx mcss init

Set up CSS runtime engine

Import master.css.ts into the entry file main.ts to enable the runtime engine.

import { initRuntime } from '@master/css';
import config from 'master.css';
initRuntime(config)

Avoid flash of unstyled content

Add display: 'none' in <html> to avoid FOUC caused by the runtime engine not yet injecting CSS rules.

<!doctype html>
<html lang="en" style="display: none">

Launch server

Run the Vite development server.

npm run dev -- --open

Hello world!

Now style your first element using Master CSS syntax!

<!DOCTYPE html>
<html lang="en" style="display: none">
<body>
<h1 class="font:40 font:heavy italic m:50 text:center">Hello World</h1>
</body>
</html>

Open your browser to watch the changes.

localhost:5173

Hello World

MIT License © Aoyue Design LLC.