Simple CSS
SCS stands for Simple Cascading Style. It is a thin
compile-time layer over css — compile-time variables, design tokens, reusable styles, functions,
components, nesting, responsive blocks, loops and explicit ordering — compiled to plain css by
MMO\client\SCSCompiler.
Everything on this page, and on The language and PHP bridge, was compiled by the real compiler while the page was being rendered: what you read as "generated css" is what your build would write.
The four rules
@xxx
a language instruction — it runs at compile time
$xxx
a compile-time variable — it is replaced, never emitted
xxx::yyy
a name another file declares — a file is a namespace
@theme
the only construct that produces runtime css variables
Pure php, no binary
Unlike the Sass pipeline, nothing is shelled out: the lexer, the parser, the evaluator and the emitter are php, so a stylesheet compiles anywhere the framework runs — no dart binary, no node, no build step to install.
Compiling
A compilation returns a Result: css(), but also
phpValue('spacing') to read back a compile-time variable and themes() to read
the design tokens the stylesheet declared. See
PHP bridge.
A real stylesheet
The demo ships a small design system in demo/www/contents/scs/ —
theme.scs (the tokens), forms.scs (the forms namespace: a style library) and
app.scs (the components). This is app.scs, compiled from disk:
Options
Every option is a property of the module: set it in the application configuration, per compilation, or
from the source itself with @config. These are the defaults this installation runs with.
| Option | Default | Description |
|---|---|---|
screens |
{"tablet":"481px","desktop":"981px","wide":"1707px"} |
named breakpoints used by @screen |
paths |
["phar:///homepages/38/d520689115/htdocs/mmoframework.fr/www/releases/3.1.4/packages/mmo.client.phar/src/styles"] |
extra directories searched by @import |
componentSelector |
".{name}" |
how @component button builds its selector |
variantSelector |
"{selector}--{variant}" |
how @variant primary builds its selector |
themeSelector |
"[data-theme=\"{name}\"]" |
how @theme dark builds its selector |
varPrefix |
"" |
prefix of every generated custom property |
indent |
" " |
indentation of the generated css |
minify |
true |
compact output |
optimize |
true |
merge consecutive identical selectors, drop overridden declarations |
resolveThemeValues |
false |
inline the token values instead of var() — runtime theming stops working |
strictFunctions |
true |
reject an unknown function instead of emitting it as css |
allowImports |
true |
set to false to refuse every @import |
sourceMap |
false |
write a .css.map next to the css (true) or inside it ('inline'), so devtools shows the .scs line |
context |
[] |
the compilation context every compilation starts with |
Where to go next
The language
every construct of the norm, side by side with the css it generates.
PHP bridge
php::, context::, the evaluation api and the trust boundary.
Playground
write your own .scs and compile it here.
Reference
the complete language reference, from docs/SimpleCSS.md.