DEV Community

Cover image for Getting started with FSCSS
FSCSS tutorial for FSCSS tutorial

Posted on Edited on Originally published at fscss.devtem.org

Getting started with FSCSS

FSCSS (Figured Shorthand Cascading Style Sheets) is a lightweight CSS preprocessor: shorter syntax, @arr arrays, @define helpers, and modules — still outputs normal CSS.

Needs Node for the CLI, or just a browser for the runtime.


1. Install

npm install -g fscss@1.2.6
Enter fullscreen mode Exit fullscreen mode

2. Three-minute runtime demo

<!DOCTYPE html>
<html>
<head>
  <script src="https://cdn.jsdelivr.net/npm/fscss@1.2.6/runtime.min.js" defer></script>
  <style>
    @import((flex-x) from flex-control)

    body {
      bg: #0e0d14;
      color: #e8e3ff;
      ff: system-ui, sans-serif;
      padding: 2rem;
    }

    .row {
      @flex-x()
      gap: 12px;
    }

    .card {
      bg: #1c1a2e;
      padding: 16px 20px;
      rounded: 12px;
    }
  </style>
</head>
<body>
  <div class="row">
    <div class="card">A</div>
    <div class="card">B</div>
    <div class="card">C</div>
  </div>
</body>
</html>
Enter fullscreen mode Exit fullscreen mode

Open the file. The runtime expands FSCSS inside <style> into real CSS.


3. CLI (production)

npm install -g fscss 
# or locally 
npm install fscss
Enter fullscreen mode Exit fullscreen mode
# styles.fscss
.box {
  p: 16px;          /* padding shorthand (1.2.5+) */
  rounded: 12px;
  bg: #12121a;
}
Enter fullscreen mode Exit fullscreen mode
fscss styles.fscss styles.css
Enter fullscreen mode Exit fullscreen mode

Link the compiled file only:

<link rel="stylesheet" href="styles.css" />
Enter fullscreen mode Exit fullscreen mode

No runtime script required.


4. Core ideas (minimal)

Idea Example
Import helpers @import((*) from st-core@v2)
Call them @st-root() / @ai-shell(.ai-shell)
Arrays @arr scores[40, 70, 90]
Shorthands p: 16px, rounded: 12px, stack: 12px

Import registers. Calling a helper emits CSS. What you don’t call doesn’t show up in the output.


5. Next

MIT · fscss-ttr

FSCSS – Lightweight CSS Preprocessor | Figured Shorthand CSS

Figured Shorthand CSS: property shorthands, @define, modules. CLI, IDE, VS Code, runtime & ESM — compiles to plain CSS.

favicon fscss.devtem.org

Top comments (0)