Cette page est affichée en anglais. Une traduction française est en cours.
ScriptsMay 20, 2026·3 min de lecture

Stylus — Expressive Dynamic CSS Preprocessor for Node.js

Stylus is a CSS preprocessor built for Node.js that offers an expressive, flexible syntax with optional colons, semicolons, and braces. It provides powerful features like transparent mixins, iteration, and interpolation while generating clean, standard CSS.

Prêt pour agents

Cet actif peut être lu et installé directement par les agents

TokRepo expose une commande CLI universelle, un contrat d'installation, le metadata JSON, un plan selon l'adaptateur et le contenu raw pour aider les agents à juger l'adaptation, le risque et les prochaines actions.

Native · 98/100Policy : autoriser
Surface agent
Tout agent MCP/CLI
Type
Skill
Installation
Single
Confiance
Confiance : Established
Point d'entrée
Stylus Overview
Commande CLI universelle
npx tokrepo install fdb63f56-5403-11f1-9bc6-00163e2b0d79

Introduction

Stylus is a CSS preprocessor created by TJ Holowaychuk (also known for Express.js and Mocha). It offers the most flexible syntax among CSS preprocessors — braces, colons, and semicolons are all optional. This minimalist approach produces clean, readable stylesheets while providing powerful features like transparent mixins, built-in functions, and iteration.

What Stylus Does

  • Compiles an indentation-based stylesheet language into standard CSS
  • Supports variables, nesting, mixins, and functions with a minimal syntax
  • Provides transparent mixins that look like native CSS properties
  • Includes built-in functions for color manipulation, math, and URL embedding
  • Integrates with Node.js build pipelines via middleware and plugins

Architecture Overview

Stylus is a Node.js-based compiler that tokenizes .styl files, builds an AST, resolves mixins and variables through lexical scoping, and emits CSS. The parser handles both the indentation-based syntax and the traditional CSS syntax interchangeably in the same file. The plugin architecture exposes the AST for transformations, enabling features like automatic vendor prefixing (via nib) and sprite generation.

Self-Hosting & Configuration

  • Install via npm: npm install stylus --save-dev
  • Integrate with webpack using stylus-loader
  • Use the nib plugin for cross-browser mixins and vendor prefixes
  • Configure Stylus middleware in Express.js for on-the-fly compilation
  • Enable source maps with --sourcemap for debugging in browser DevTools

Key Features

  • Optional syntax — write CSS without braces, colons, or semicolons
  • Transparent mixins that blend seamlessly with native CSS properties
  • Iteration and conditionals (for, if/else) for generating repetitive CSS
  • Powerful built-in functions: darken(), lighten(), rgba(), unit()
  • Rest params and argument introspection in mixin definitions

Comparison with Similar Tools

  • Sass/SCSS — larger ecosystem and community; Stylus offers more syntactic freedom
  • Less.js — closer to CSS syntax; Stylus allows a more concise, Python-like style
  • PostCSS — plugin-based transformer; Stylus is a complete preprocessor language
  • Tailwind CSS — utility-first approach; Stylus is for writing custom component-scoped styles

FAQ

Q: Is Stylus still maintained? A: The project receives maintenance updates. The core feature set is stable and complete for production use.

Q: Can I mix Stylus and regular CSS syntax? A: Yes. Stylus accepts both indentation-based syntax and standard CSS in the same file.

Q: Does Stylus work with Vue.js single-file components? A: Yes. Vue supports <style lang="stylus"> blocks natively with the appropriate loader.

Q: How does Stylus handle vendor prefixes? A: Use the nib library, which provides transparent mixins that automatically add vendor prefixes where needed.

Sources

Fil de discussion

Connectez-vous pour rejoindre la discussion.
Aucun commentaire pour l'instant. Soyez le premier à partager votre avis.

Actifs similaires