Introduction
Get a quick overview of Master CSS and its benefits.
What is Master CSS?
The CSS language and framework for rapidly building modern and high-performance websites.
Whether you're a solo developer or part of a large team, Master CSS can help you build the fastest and beautiful websites.
The CSS language
Master CSS is a markup-driven CSS language with smart rules allowing you to write familiar CSS using concise syntax within HTML/JSX.
Under the hood, Master CSS automatically adds vendor prefixes, smartly ordering CSS rules, and more. This allows you to focus on building your website rather than spending a lot of effort writing and maintaining CSS rules.
Hello World
<h1 class="fg:indigo fg:red:hover font:32 font:40@sm font:heavy m:10x text:center"> Hello World</h1>
Declaring styles through the class
attribute, attaching selector states, and even base them on conditional queries. There's no need to write any inline style sheets, including creating external CSS files; just add syntax classes in your HTML.
You can write atomic classes text:center
or abstract styles btn
based on the characteristics of your project and team.
The CSS framework
Master CSS is a standalone CSS framework that provides various packages and solutions to expedite the development, including integrations for popular JavaScript frameworks, code linting for unifying team style, language service to enhance the developer experience, configuration API for design systems, and more.
Package | Description |
---|---|
Main | |
@master/css | The CSS language and framework for rapidly building modern and high-performance websites |
@master/css-runtime | Run Master CSS right in the browser |
@master/css-server | Render Master CSS on the server side |
@master/css-extractor | Master CSS static extractor for various raw text |
@master/css-validator | Validate Master CSS syntax |
@master/css-cli | Master CSS CLI |
@master/create-css | Initialize a new Master CSS project |
Integrations | |
@master/css.react | Integrate Master CSS in React way |
@master/css.svelte | Integrate Master CSS in Svelte way |
@master/css.vue | Integrate Master CSS in Vue way |
@master/css.nuxt | Integrate Master CSS Progressive Rendering in Nuxt way |
@master/css-extractor.vite | Integrate Master CSS Static Extraction in Vite way |
@master/css-extractor.webpack | Integrate Master CSS Static Extraction in Webpack way |
Developer Tools | |
@master/eslint-config-css | Master CSS ESLint Config |
@master/eslint-plugin-css | Master CSS ESLint Plugin |
@master/css-language-server | Master CSS Language Server |
@master/css-language-service | Master CSS Language Service |
master-css-vscode-language-service | Master CSS Language Service for Visual Studio Code |
Other Solutions | |
@master/colors | A crafted color system for beautiful user interfaces |
@master/normal.css | Normalize browser's styles ~600B |
theme-mode | A lightweight utility for switching CSS theme modes |
class-variant | Create reusable and extensible style class variants |
Is the framework you're using not mentioned above? Check out the official installation guides.
Why Master CSS?
The reasons why to use Master CSS with an overview of features, syntax benefits, benchmarks, and a comprehensive comparison:
Rendering Modes
Master CSS provides three rendering modes, and you can choose according to project scale and application scenarios to meet your business needs.
One of the most unique, the progressive rendering works by pre-rendering the critical CSS based on the element's class names and deferring the loading of the runtime engine for any future dynamic class names.
<!DOCTYPE html><html lang="en"><head> … <style id="master">.block{display:block}</style> <script src="https://cdn.master.co/css-runtime@rc" defer></script></head><body> <h1 class="block">Hello World</h1></body></html>
This ensures the page generates the ultra-lightweight CSS and the fastest first-page render, unlike traditionally bundling styles across the entire application.
Design System APIs
Master CSS provides a set of systematic configuration APIs to help you build a consistent, easy-to-manage, and scalable design system:
Option | Description |
---|---|
Animations | Customizing animation keyframes for your design system. |
Functions | Customizing functions for your design system. |
Queries | Customizing feature queries and breakpoints for your design system. |
Rules | Customizing syntax rules for your design system. |
Selectors | Customizing selectors for your design system. |
Semantics | Customizing semantic classes for your design system. |
Styles | Customizing abstract styles for your design system. |
Variables | Customizing variables for your design tokens. |
We have built a series of neutral tokens in the default configuration and created a universal Master Design System, which make your design system on top of or use it as a quick starting point.
Variable | Description |
---|---|
Colors | Customizing color variables or starting with the crafted palette. |
Base Colors | Customizing base color variables or starting with the official design system. |
Text Colors | Customizing text color variables or starting with the official design system. |
Fonts | Customizing fonts for your design system. |
Screens | Customizing screens and breakpoints or starting with the official design system. |
Spacing and Sizing | Apply consistent sizes across your application. |
This is just one part; more design variables and tokens are scattered throughout the syntax documentation.
For example, the semantic class capitalize
is used to simplify text-transform: capitalize
:
Heavy Boxes Perform Quick Waltzes And Jigs.
<p class="capitalize">Heavy Boxes Perform Quick Waltzes And Jigs.</p>
Syntax Highlighting
Master CSS is the first language to highlight class names fully, making identifying their properties, appearance, and state faster.
Do you find writing utility classes sometimes seem lengthy or hard to read?
<div class="sm:hover:bg-[#ceb195] …">
Light up your class names in markup from now on!
<div class="bg:#ceb195:hover@sm …">
This feature is included in the Master CSS Language Service.
Code Linting
Have you ever felt anxious about adding styles to class attributes? Master CSS was the first to introduce syntax validation of classes in template markup, which helps you find errors early before building and dramatically improves the developer experience.
Invalid value for `font` property.
<div class="font:">…</div>
This is just a piece of cake; we also allow you to enforce consistent class ordering, legitimate class checks, class collision checks, and checks for JavaScript utilities like clsx()
.
To learn more, check out the Code Linting documentation.
Minimal CSS on the market
Initially, Master CSS was intended to create a CSS engine for production browser runtimes, so we concentrated on performance such as syntax parsing, rule generation, cache sharing, and even browser rendering.
Master CSS doesn't use heavy-duty build tools like PostCSS, Autoprefixer, or any minifiers, as these rules are generated with optimization.
This is a real-world benchmark of critical CSS on page load for well-known official documentation websites.
According to HTTP Archive CSS Bytes, the sum of transfer size kilobytes of all external stylesheets requested by the page is ~82 kB, excluding internal and inline styles.
Master CSS only injects the CSS required by the page, so the official documentation site is super tiny, about ~6 kB per page (brotli).
Comparisons
Here’s a comprehensive comparison of Master CSS, Tailwind CSS and Bootstrap:
Language | - | - | |
---|---|---|---|
Framework | |||
Rendering | |||
Runtime Rendering | Dev JIT | ||
Server-side Rendering | |||
CSS Hydration | |||
Static Extraction | |||
Preprocessors | |||
PostCSS | No | Yes | Yes |
Autoprefixer | No | Yes | Yes |
CSS minifiers | No | Yes | Yes |
Resource Size | |||
Critical CSS for initial paint | Minimal | Largest | ~233 KB |
Source that generates CSS | Page | All files | - |
Generate redundant CSS rules | No | Yes | Yes |
Render-blocking CSS resources | Internal | External | External |
Programming | |||
The class names from server | - | ||
The class names from static files | Unreliable | - | |
The ability to customize tokens | |||
Breakpoints and Screens | 11 | 5 | 5 |
Colors | ~222 | ~244 | ~100 |
Variables with Modes | |||
Queries | |||
Selectors | |||
Abstract Styles | @apply | Predefined | |
Language Service | |||
Code-completion | |||
Syntax highlighting for class names | |||
CSS generate preview | |||
Code Linting for Markup | |||
Consistent class order | |||
Syntax error checks | |||
Disallow unknown classes | |||
Class collision detection |
Get ready for the journey
You can embark on an in-depth study of Master CSS without prior CSS expertise. Each document features demonstrations and fundamental usages of the intended functionalities.
The Master CSS helps you lower the threshold for learning CSS.
Use documentation
A few notes on using these documents:
-
Get an overview of almost all the documents via the navigation on the left side of the screen, and there are only a few categories:
- Getting Started for installation, setting up developer tools, and migration guides.
- Syntax Tutorial for learning the core syntax.
- Fundamentals for understanding core principles and concepts.
- Design Variables for customizing design tokens.
- Configuration for customizing your syntax.
- Production Optimization for minimization and performance.
- Syntax for all syntax references.
-
On the right side, you'll see a table of contents that makes navigating between page sections easier.
-
Click the search box on the left side or use the shortcut Ctrl + K or ⌘ Command + K to search the entire site.
-
Every class name in the document can preview the generated CSS rules by hovering.
<div class="hidden@<sm&>md">Try hovering over the class</div>
Try Master CSS online
You can use the official Master CSS Play to edit, preview, view the generated size, and even share your design online.
Join our community
If you have questions about Master CSS, you're always welcome to ask our community on:
- GitHub Discussions: Ask questions and share insights.
- Discord: Join real-time conversations with humans.
- Twitter: Stay updated on Master CSS
We're here to support your Master CSS journey!