CSS Syntax (with Stylus)
Browse / Stylus CSS Preprocessor Cheatsheet
Stylus CSS Preprocessor Cheatsheet
A comprehensive cheat sheet covering Stylus, a CSS preprocessor, with syntax, features, and practical examples to enhance your CSS workflow.
Getting Started with Stylus
Basic Syntax
|
|
|
|
Indent Syntax (Stylus) |
Stylus supports both CSS and indented syntax. |
|
Key Differences |
|
Variables
|
Defining Variables |
Variables store values for reuse. |
|
Conditional Assignment |
|
Mixins
|
Basic Mixin |
Reusable blocks of declarations. |
|
Mixin with Arguments |
Mixins can accept arguments for customization. |
|
Argument Defaults |
Arguments can have default values. |
|
Block Mixins |
Mixins that wrap blocks of code. |
|
Rest Params |
Allows accepting variable number of arguments. |
Functions and Operators
Functions
|
Defining Functions |
Functions perform calculations and return values. |
|
Argument Defaults in Functions |
Arguments can have default values if not provided. |
|
Named Parameters |
Arguments can be passed by name. |
|
Multiple Return Values |
Functions can return multiple values as a list. |
Values and Interpolation
|
Property Lookup |
Refer to other property values. |
|
Interpolation |
Dynamically construct property names and values. |
Color Operators
|
Stylus provides operators to manipulate colors:
|
|
Casting
|
Advanced Features
Conditionals
|
If/Else Statements |
Control flow based on conditions. |
|
Aliases |
|
Loops
|
For Loops |
Iterate over a range of values. |
Definition and Type Checks
|
Definition Check |
Check if a variable is defined. |
|
Type Check |
Check the type of a value. |
Built-in Functions and Utilities
Color Functions
|
Alpha |
Get the alpha (transparency) value of a color. |
|
Dark/Light |
Check if a color is dark or light. |
|
Hue/Saturation/Lightness |
Extract color components. |
|
Adjusting Color Components |
Set color components. |
|
Color Manipulation |
Modify color properties. |
|
Tint/Shade |
Mix colors with white or black. |
Utility Functions
|
Unquote |
Removes quotes from a string. |
|
Image Size |
Returns the width and height of an image. |
|
Caching |
Caches the result of a mixin. |
|
Add Property |
Adds a property to the current block. |
|
Sprintf |
|
|
Embed URL |
Embeds a file as a data URL. |