Installation

Set up Master CSS in Laravel

Guide to setting up Master CSS in your Laravel 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 example.

You can skip all installation steps.

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

Launch server

Run Laravel and Vite development servers by splitting two terminals.

php artisan serve

Installation

Create a project

If you don't have a Laravel project, create one first. It's recommended to refer to Installation - Laravel

composer create-project laravel/laravel example-app

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.js.

npx mcss init

Set up CSS runtime engine

Import master.css.js config and initialize the runtime engine in your resources/js/app.js file.

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

Set up your view layout

Include the following in your resources/views/layouts/welcome.blade.php:

  • Import the entry by adding @vite('resources/js/app.js')
  • Add display: none to <html> to avoid FOUC
<!DOCTYPE html>
<html style="display: none" lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
@vite('resources/js/app.js')
</head>
</html>

Launch server

Run Laravel and Vite development servers by splitting two terminals.

php artisan serve

Hello world!

Now style your first element using Master CSS syntax!

<body>
<h1 class="font:40 font:heavy italic m:50 text:center">
Hello World
</h1>
</body>

Open your browser to watch the changes.

127.0.0.1:8000

Hello World

MIT License © Aoyue Design LLC.