FSCSS Documentation
Figured Shorthand CSS is a powerful CSS preprocessor that simplifies your stylesheets with intuitive shorthand syntax, reusable patterns, and enhanced functionality.
Get StartedWhy Use FSCSS?
FSCSS streamlines your CSS workflow with features designed to reduce repetition, improve readability, and enhance maintainability of your stylesheets.
Faster Development
Write complex CSS with significantly less code using intuitive shorthand syntax
Improved Maintainability
Reuse styles and variables across your project for consistent updates
Enhanced Readability
Clear, concise syntax makes your stylesheets easier to understand
Variables
FSCSS variables give you flexible ways to store and reuse values across your stylesheets. They can be inline, scoped to elements, global, or even store entire blocks of styles. Define once, reuse anywhere.
Key Features
- Inline variables:
$name: value;
β used with$name!
- Global variables:
$global: value;
β available everywhere - Local (scoped) variables: defined inside a selector, used only in that block
- Block variables:
str(name, "block of styles")
β store whole chunks of CSS - All variables compile down to native CSS
--custom-properties
Inline & Global Variables
// Inline & global variables
$primary: #3b82f6;
$secondary: #8b5cf6;
$global-font: 'Inter', sans-serif;
.button {
background: $primary!;
border: 2px solid $secondary!;
font-family: $global-font!;
}
Local Variables (Scoped)
.card {
$local-bg: #f1f5f9;
background: $local-bg!;
padding: 1rem;
}
Block Value Variables
Block variables let you store reusable style snippets as text, then inject them wherever needed.
str(shadowBlock, "
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
border-radius: 0.75rem;
");
.card {
background: white;
shadowBlock
}
Style Replacement
Store reusable style patterns and inject them wherever needed. Perfect for maintaining consistent styles across components and reducing repetition in your stylesheets.
When to Use
- Creating reusable style patterns
- Maintaining consistent component styles
- Reducing repetition in your stylesheets
- Applying complex styles with a simple reference
Practical Example
// Store a card style pattern
str(cardStyle, "
padding: 1.5rem;
border-radius: 8px;
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
background: white;
transition: transform 0.3s ease;
")
// Store a hover effect
str(cardHover, "
transform: translateY(-5px);
box-shadow: 0 10px 15px rgba(0,0,0,0.1);
")
// Apply stored styles
.product-card {
cardStyle
max-width: 300px;
&:hover {
cardHover
}
}
.user-profile {
cardStyle
background: #f0f9ff;
}
Repeat Function rpt()
Need to generate repeating characters, units, or patterns without writing them manually?
The rpt()
function repeats any value a specified number of times.
Great for content, backgrounds, and decorative effects.
Practical Example
// Decorative separator
.separator::after {
content: "rpt(10, 'β ')";
display: block;
text-align: center;
color: #94a3b8;
margin: 1rem 0;
}
Copy Function copy()
The copy()
function extracts part of a value or string and stores it as a variable.
Perfect for working with design tokens, colors, or long values you only want to write once.
Practical Example
body {
background: #4ff000 copy(4, primary-color);
color: $primary-color!;
}
@ext()
β Value & String Extractor
@ext()
lets you slice strings or values by index and store them as variables.
Think of it as substring extraction, but directly inside your CSS.
Example
body {
property: "the red color @ext(4,3: myRed)";
color: @ext.myRed;
}
mx() / mxs()
Use mx()
and mxs()
to quickly apply multiple properties with the same value.
mxs()
takes a shared value string, while mx()
requires appending colons manually.
Use Cases
Consistent Box Sizes
.card {
mxs(width, height, max-height, max-width, min-width, min-height, '200px')
}
Flexible Value Declaration
.box {
mx(width, height, max-height, max-width, min-width, min-height, ': 200px;')
}
Practical Example
.card {
mxs(width, height, max-height, max-width, min-width, min-height, '200px')
}
.box {
mx(width, height, max-height, max-width, min-width, min-height, ': 200px;')
}
AD
Attribute Selector Shortcut
FSCSS makes attribute selectors faster to write.
For example, $(type:submit)
compiles to [type='submit']
.
This is handy for forms, input types, roles, and any attribute-based selection.
Use Case
Target Form Buttons
$(type:submit) {
background: green;
color: white;
}
$(type:submit) {
background: green;
color: white;
}
[type='submit'] {
background: green;
color: white;
}
Keyframes Compact
FSCSS lets you define and apply animations in one block with
$(@keyframes name, selectors, &[duration timing options])
.
It generates both the @keyframes
and applies the animation to your elements automatically.
Use Case
Slide Animation
$(@keyframes slideIn, .box, .card, &[3s linear infinite]) {
from { transform: translateX(-100%); }
to { transform: translateX(0); }
}
$(@keyframes slideIn, .box, .card, &[3s linear infinite]) {
from { transform: translateX(-100%); }
to { transform: translateX(0); }
}
.box, .card {
animation: slideIn 3s linear infinite;
}
@keyframes slideIn {
from { transform: translateX(-100%); }
to { transform: translateX(0); }
}
Vendor Prefixing (-*-)
Use the -*-
prefix to automatically apply vendor-specific properties across
-webkit
, -moz
, -ms
, and -o
.
This ensures cross-browser compatibility without writing each prefix manually.
Use Case
Cross-Browser Transforms
.box {
-*-transform: rotate(45deg);
}
.box {
-*-transform: rotate(45deg);
}
.box {
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-ms-transform: rotate(45deg);
-o-transform: rotate(45deg);
transform: rotate(45deg);
}
Function Based (@fun)
FSCSS allows defining reusable groups of values with @fun(name){...}
.
These can store sizes, colors, or property sets and can be referenced anywhere using dot-notation.
Use Case
Reusable Palette & Sizes
@fun(e){
a: 100px;
b: 200px;
}
@fun(col){
1: #550066;
2: #005523;
}
.box {
width: @fun.e.a.value;
height: @fun.e.b.value;
background: linear-gradient(@fun.col.1.value, @fun.col.2.value);
}
@fun(e){
a: 100px;
b: 200px;
}
@fun(col){
1: #550066;
2: #005523;
}
.box {
width: @fun.e.a.value;
height: @fun.e.b.value;
background: linear-gradient(@fun.col.1.value, @fun.col.2.value);
}
.box {
width: 100px;
height: 200px;
background: linear-gradient(#550066, #005523);
}
AD
Array Method (@arr)
The @arr()
directive lets you define reusable arrays of valuesβideal for staggered animations, theming, and scalable utilities.
Arrays are 1-indexed (starting from [1]
), and can store numbers, colors, strings, or any valid CSS value.
Use Case
Animating with Arrays
@arr(e[0.1, 2.5, 7]);
@arr(col[red, blue, green]);
section {
background: @arr.col[2];
}
section :nth-child(@arr.e[]) {
animation: spin 3s linear infinite;
animation-delay: @arr.e[]s;
background: @arr.col[3];
}
@arr(e[0.1, 2.5, 7]);
@arr(col[red, blue, green]);
section {
background: @arr.col[2];
}
section :nth-child(@arr.e[]) {
animation: spin 3s linear infinite;
animation-delay: @arr.e[]s;
background: @arr.col[3];
}
@keyframes spin {
0% { transform: rotate(0); }
100% { transform: rotate(360deg); }
}
section {
background: blue;
}
section :nth-child(1) {
animation: spin 3s linear infinite;
animation-delay: 0.1s;
background: green;
}
section :nth-child(2) {
animation: spin 3s linear infinite;
animation-delay: 2.5s;
background: green;
}
section :nth-child(3) {
animation: spin 3s linear infinite;
animation-delay: 7s;
background: green;
}
@keyframes spin {
0% { transform: rotate(0); }
100% { transform: rotate(360deg); }
}
π²@random()
Method
The @random()
method lets you apply randomized values to CSS properties, enabling dynamic, ever-changing styles without JavaScript. When combined with @arr()
, it becomes a powerful tool for reusable random styling.
π§ Syntax Overview
@random([value1, value2, value3, ...])
Returns a randomly selected value from the array on each stylesheet render.
β¨ Example: Randomized Button Style
.btn {
padding: 10px 20px;
margin: 10px;
background: @random([lightgreen, yellow, gray]);
color: @random([midnightblue, blue, green]);
border: 2px groove @random([#4361ee, #f72585, #7209b7]);
transform: translate(@random([10,30,60])px);
rotate: @random([0,90,150])deg;
}
Each page load applies a new combination of background, color, translation, and rotation to .btn
.
π§© What You Can Build With It
- Random button colors or positions
- Playful or animated UI elements
- Fast prototyping with automatic variations
π Benefits
Dynamic UI: Fresh styles every reload - Reusable: Combine with
@arr()
- No JS Needed: Pure FSCSS logic
- Clean Syntax: Short and maintainable
π Summary
FSCSS @random()
makes randomized styling effortlessβperfect for motion, contrast, or playful designs without relying on JavaScript.
βοΈcopy()
Function
The copy()
function is used to extract and reuse parts of string values, making it ideal for design tokens, dynamic variables, or text-based CSS manipulation.
π§ Syntax Overview
copy(length, variable)
- length: Number of characters to extract
- Positive β from the start
- Negative β from the end
- Larger than string β returns full string
- variable: The FSCSS variable name to store the extracted result
β¨ Example Usage
body {
/* primary-color = #4ff */
background: #4ff000 copy(4, primary-color);
color: $primary-color!;
}
a {
color: $primary-color!;
}
span:before {
content: "blue or midnightblue copy(-14, my-darkblue)";
border: 2px solid $my-darkblue!;
}
π§ How It Works
copy(4, primary-color)
β extracts first 4 chars of#4ff000
β#4ff
- Stores result in
$primary-color
, reusable anywhere copy(-14, my-darkblue)
β extracts last 14 chars from the string βmidnightblue
β Best Practices
- Use descriptive variable names for extracted values
- Double-check string length when using negative values
- Perfect for color tokens, naming consistency, and reusability
π Summary
FSCSS copy()
enables powerful string slicing and variable reuse, bringing DRY principles and token-based design to your stylesheets.
@num()
β String to Number
The @num()
method allows inline numeric calculations directly in your stylesheets.
You can perform arithmetic like num(40 * 2)
β 80
, and append units such as num(4 * 6)px
β 24px
.
π§ Syntax Overview
@num(expression)
- expression: Any valid arithmetic using
+ - * /
- Units: Append units like
px
,%
,em
, etc.
β¨ Example Usage
1. Calculating max-height
selector {
max-height: num(40 * 4); /* = 160 */
}
2. Mix with @random for dynamic values
textarea {
max-height: num(@random([40, 10, 5, 0]) + 50);
}
π§ How It Works
num(40 * 4)
β evaluates to160
num(10 + 20)px
β compiles to30px
num(@random([5, 15]) * 2)
β produces either10
or30
π§© What You Can Build With It
- Responsive calculations without JS
- Dynamic values with
@random()
and@arr()
- Reusable math for animations, spacing, and sizing
β Best Practices
- Keep expressions simple for readability
- Pair with
@random()
and@arr()
for dynamic patterns - Use variables for clarity:
@num($spacing * 2)
- Validate unit compatibility when mixing values
π Summary
- Lightweight Calculation: Compute values inline with
+ - * /
- Supports Units: Works with
px
,%
,em
, etc. - Dynamic Pairing: Combine with
@random()
,@arr()
,@fun()
, and variables - Cleaner Code: Math in stylesheets, no JS required
Detailed Exploration of FSCSS
FSCSS, an acronym for Figured Shorthand Cascading Style Sheet, emerges as a promising methodology within the realm of web development, specifically aimed at enhancing the efficiency and readability of CSS (Cascading Style Sheets).
Definition and Purpose
FSCSS is defined as a styling approach designed to simplify CSS by introducing shorthand notations. The primary objective is to reduce repetitive code, thereby making styles more concise and easier to maintain.
This methodology rethinks traditional CSS writing, focusing on efficiency without compromising functionality. For instance, it aims to address the common challenge of bloated CSS files, which can hinder performance and readability, especially in large-scale projects.
The evidence leans toward FSCSS being particularly beneficial for developers seeking clean and maintainable CSS structures. This is supported by its emphasis on reducing redundancy, a common pain point in web development where stylesheets can become unwieldy over time.
Key Features and Functionality
-
Shorthand Methods: Use of notations like
%2
to share values across multiple properties, reducing repetitive declarations. - Rapid Tag Formatting (rtF): Style multiple elements quickly, useful for lists, grids, and modular design.
- Animation Efficiency: Compact syntax for defining animations, making them easier to manage.
- Script Integration: Compatibility with FSCSS-specific scripts and tools to automate or enhance styling processes.
These features collectively address modern development needs where performance and maintainability are critical.
Use Cases and Adoption
- Enterprise-level websites needing consistent styling
- Startup projects aiming for scalability
- Developers working under tight deadlines for faster delivery
Introducing FSCSS: Figured Shorthand Cascading Style Sheet
We hope you have an excellent experience exploring its features and capabilities.
The FSCSS journey began in 2022, conceived by David Hux as a robust testing framework. Early development by Figsh focused on core concepts like %2
to %6
, %i
, and basic variable handling using $...
.
Building on this foundation, FSCSS quickly evolved. As outlined in the official documentation, the framework now includes:
- Shorthand methods
%1()
to%6()
- Powerful merging tools like
mx()
andmxs()
- String manipulation with
str()
andre()
- Reusable value extraction with
copy()
- Advanced variable handling like
$...:...
and$...!
- Support for
@keyframes
and advanced selector patterns with$(... :...)
2023 marked a significant milestone with the copy()
function and the frameworkβs first public release for testing.
2024 introduced improved preprocessor memory and new functions, leading into 2025 with the official npm package release of fscss
.
This latest release includes:
- An advanced
replace
function for full string matching - Expanded
%n()
method supporting infinite counting - Developer-friendly console logs and debugging tools
- Direct execution via the FSCSS browser extension
FSCSS is officially published under the Figsh organization as the fscss
package on npm. Led by David Hux and managed through the fscss-ttr initiative, it promotes collaboration and learning in the developer community.
You can find tutorials and community support on:
- dev.to
- CodePen
- X (formerly Twitter)
- YouTube
- Stack Overflow
- Quora
- GitHub
FSCSS File Structure Overview
-
/exec.min.js
(from jsDelivr)A minified version of the executable JavaScript file. βMinifiedβ means unnecessary characters like spaces and comments are removed, making the file smaller and faster to load. Delivered via jsDelivr, a global Content Delivery Network (CDN) for efficient delivery.
-
/exec.js
(original)The original, un-minified version of the executable JavaScript file. This version is easier for developers to read and debug. The minified
exec.min.js
is typically generated from this for production deployment. -
/index.js
(npm default)The standard entry point for JavaScript projects using npm (Node Package Manager). When a project is run or imported as a package,
index.js
is the first file executed. -
/xfscss.min.js
(for importation)A minified JavaScript file designed to handle FSCSS functions, such as dynamic CSS processing and styling within JavaScript environments. Optimized for production use and integration via script imports.
-
/e/
(available in version 1.1.6+)A directory/module introduced in version 1.1.6 containing utilities for error handling and logging. Provides developer-friendly tools for debugging and diagnostics, helping identify and fix issues during development.