Static CSS Generation

Static CSS Generation (SCG) allows you to pre-generate CSS from HTML.

Overview

If you prefer pre-generating your CSS without relying on the runtime engine, You can use Mojo's Static CSS Generation (SCG) module.

Usage


  1. Import the SCG Module:

import MojoSCG from "mojocss/src/interop/scg.js"
  1. Create an Instance:

const htmlString = ""; // Static HTML content
const config = {}; // Mojo's Configuration options
const scg = new MojoSCG(htmlString, config)
  1. Call the Render Method:

const css = scg.render();
  1. Use the Generated CSS:

The css variable contains the generated CSS styles. You can inject these styles into a <style> tag inside the <head> section of your HTML document.