Set up Master CSS in Vue.js


Guide to setting up Master CSS in your Vue.js 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 ~17KB transfer cost

Fully automatic

Capture any program-generated class names

CSS lifecycle

Generated on-demand and frees memory when not in use

A full-stack framework, such as Nuxt.js, is recommended for better application performance and experience.

Quick start

Clone the example

Copy-paste the commands to quickly start using the example.

You can skip all installation steps.

npm create @master/css@rc project --example vue.js
cd project
npm run dev


Create a project

If you don't have a Vue.js project, create one first. It's recommended to refer to Quick Start - Vue.js.

npm init vue@latest
cd project

Initialize configuration file

Run npm create @master/css@rc to create a configuration file master.css.ts.

npm create @master/css@rc

Install Master CSS

Install Master CSS Vue into your project via package managers.

npm install @master/css.vue@rc

Set up CSS runtime engine

  • Import your custom configuration master.css.ts
  • Initialize the runtime engine using CSSRuntimeProvider
<script setup lang="ts">
import CSSRuntimeProvider from '@master/css.vue'
import config from '../master.css'
<CSSRuntimeProvider :config="config">

Prevent 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 npm run dev to start your Vite development server

npm run dev

Start using Master CSS

Now style your first element using Master CSS syntax!

<CSSRuntimeProvider :config="config">
<h1 class="font:40 font:heavy italic m:12x text:center">Hello World</h1>

Open your browser to watch the changes.


Hello World

© Aoyue Design LLC.