FSCSS Documentation

Figured Shorthand CSS is a powerful CSS preprocessor that simplifies your stylesheets with intuitive shorthand syntax, reusable patterns, and enhanced functionality.

Get Started

Why 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 provide a powerful way to store and reuse values throughout your stylesheets. Define once, use everywhere.

Key Features

- Define variables with $name: value;

- Reference variables with $name!

- Variables compile to CSS custom properties

- Scoped to :root by default

Basic Usage

fscss
// Define color variables
$primary: #3b82f6;
$secondary: #8b5cf6;
$text: #1e293b;

// Use variables
.button {
  background: $primary!;
  color: white;
  border: 2px solid $secondary!;
}

.heading {
  color: $text!;
  font-size: 2rem;
}
compiled css
:root {
  --primary: #3b82f6;
  --secondary: #8b5cf6;
  --text: #1e293b;
}

.button {
  background: var(--primary);
  color: white;
  border: 2px solid var(--secondary);
}

.heading {
  color: var(--text);
  font-size: 2rem;
}

Style Replacement (str(), re(), store())

Store reusable style patterns and inject them wherever needed. Perfect for maintaining consistent styles across components.

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

fscss
// 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())

Generate repeated patterns, content, or values with the rpt() function. Ideal for visual indicators, loading states, and generated content.

Use Cases

Loading Indicators
.loading::after {
  content: "rpt(5, '• ')";
}
Visual Ratings
.rating-4::before {
  content: "rpt(4, '★')";
  color: gold;
}
fscss
// Create a decorative separator
.separator::after {
  content: "rpt(10, '— ')";
  display: block;
  text-align: center;
  color: #94a3b8;
  margin: 1rem 0;
}

// Generate background pattern
.grid-bg {
  background-image: 
    linear-gradient(90deg, 
      rgba(0,0,0,0.1) 1px, 
      transparent 1px),
    linear-gradient(180deg, 
      rgba(0,0,0,0.1) 1px, 
      transparent 1px);
  background-size: 
    rpt(8, '20px ') 100%, 
    100% rpt(8, '20px ');
}

Copy Function (copy())

Extract and reuse parts of values with the copy() function. Perfect for working with design tokens and value lists.

How It Works

copy(length, variable) extracts the value at the specified length to a variable

Practical Example

fscss

body{
  /* primary-color = #4ff */
  background:#4ff000 copy(4, primary-color);
  color: $primary-color!;
}
          /* use it in any sheets */
          a{
            color: $primary-color!;
          }
span:before{
          /* copy 'midnightblue' and store it as 'my-darkblue' */
          content: "blue or midnightblue copy(-13, my-darkblue)";
          border: 2px solid $my-darkblue!;
         } 
Understand more about the copy function

@ext() – Value & String Extractor

The @ext() method in FSCSS (Figured Shorthand CSS) is a **value and string slicing utility**. It extracts a substring from a given property string or value using index-based parameters, stores it as a named variable, and allows it to be reused across your styles.

🔧 Syntax

@ext(startIndex, length: variableName)

- startIndex: The position to start extraction. Use negative values to count from the end.
- length: How many characters to extract.
- variableName: The alias name to store the result.

📦 Example

Extract “red” from a property string
body {
  property: "the red color @ext(4,3: myRed)";
  color: @ext.myRed;
}

- Starts at index 4 ("the red") and extracts 3 characters.
- Stores as @ext.myRed which is reused for the color property.

Extracting from the end of the string
h1 {
  content: "Welcome to FSCSS @ext(-5,5: brand)";
  font-family: @ext.brand;
}

- Starts 5 characters from the end and extracts 5.
- Useful for capturing trailing identifiers or dynamic fragments.

✨ Summary

  • Dynamic Extraction: Pull values or keywords directly from inline strings.
  • Position-Based Logic: Use positive or negative indexing for full control over slicing.
  • Reusable Variables: Store extracted values under named variables (e.g. @ext.myRed) to reference multiple times.
  • Lightweight & Inline: Eliminates redundancy and simplifies styling patterns involving repeated content.

mx() / mxs() Mixins

Use mx() and mxs() to quickly apply multiple properties with the same value. mxs uses 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;')
}
fscss
.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;')
}
css
.card {
  width: 200px;
  height: 200px;
  max-height: 200px;
  max-width: 200px;
  min-width: 200px;
  min-height: 200px;
}
.box {
  width: 200px;
  height: 200px;
  max-height: 200px;
  max-width: 200px;
  min-width: 200px;
  min-height: 200px;
}

AD

Shared Properties (%1 - %6, %i)

Shared values are assigned to indexes like %2, %3, and so on. They can be injected directly into selectors using shorthand to reduce repetition when multiple properties share the same value.

Use Cases

%2 - Two Properties, One Value
div{%2(width, height[: 50px;])}
%3 - Three Properties, One Value
.box{%3(border-radius, outline-width, min-width[: 5px;])}
%4 - Four Properties, One Value
h1{%4(margin, padding, gap, inset[: 10px;])}
%5 - Five Properties, One Value
button{%5(border-width, font-size, line-height, letter-spacing, word-spacing[: 2px;])}
%6 - Six Properties, One Value
.grid{%6(row-gap, column-gap, padding, margin, top, left[: 1rem;])}
fscss
div {
  %2(width, height[: 50px;])
}

.box {
  %3(border-radius, outline-width, min-width[: 5px;])
}

h1 {
  %4(margin, padding, gap, inset[: 10px;])
}

button {
  %5(border-width, font-size, line-height, letter-spacing, word-spacing[: 2px;])
}

.grid {
  %6(row-gap, column-gap, padding, margin, top, left[: 1rem;])
}
css
div {
  width: 50px;
  height: 50px;
}

.box {
  border-radius: 5px;
  outline-width: 5px;
  min-width: 5px;
}

h1 {
  margin: 10px;
  padding: 10px;
  gap: 10px;
  inset: 10px;
}

button {
  border-width: 2px;
  font-size: 2px;
  line-height: 2px;
  letter-spacing: 2px;
  word-spacing: 2px;
}

.grid {
  row-gap: 1rem;
  column-gap: 1rem;
  padding: 1rem;
  margin: 1rem;
  top: 1rem;
  left: 1rem;
}

Hope you understand or learn from the %2() example: %2 applies the same value to 2 properties, %3 does the same for 3, and so on up to %6. It's a great way to reduce repetition in FSCSS.

Attribute Selector Shortcut

Shorthand for attribute selectors. Converts $(type: submit) into [type='submit'].

Use Cases

Target Form Buttons
$(type:submit) {
  background: green;
  color: white;
}
fscss
$(type:submit){
  background: green;
  color: white;
}
css
[type='submit'] {
  background: green;
  color: white;
}

Keyframes Compact

Write animations compactly using $(@keyframes name, selectors, &[<timing>]). FSCSS will expand this into both animation rules and the actual keyframe block.

Use Cases

Slide Animation
$(@keyframes slideIn, .box, .card, &[3s linear infinite]) {
  from { transform: translateX(-100%); }
  to { transform: translateX(0); }
}
fscss
$(@keyframes slideIn, .box, .card, &[3s linear infinite]) {
  from { transform: translateX(-100%); }
  to { transform: translateX(0); }
}
css
.box, .card {
  animation: slideIn 3s linear infinite;
}
@keyframes slideIn {
  from { transform: translateX(-100%); }
  to { transform: translateX(0); }
}

Fast Application of Animation to Multiple Selectors
This "fscss" snippet demonstrates a concise way to define and apply a CSS animation to multiple HTML elements (div, h1, h2, p) simultaneously. It encapsulates the @keyframes definition and its application within a single, streamlined block. The output automatically generates the @keyframes rule with an animation name derived from the first selector (in this case, div), and then applies this animation to all specified elements with the designated duration and timing function.

fscss Input:
fscss
$(@keyframes div, h1, h2, p &[5s ease-in]){
          0%{ color: #001133;} 
          50%{ color: #001044;} 
          100%{ color: #000122;}
          }
CSS output:
css
div, h1, h2, p {animation:div 5s ease-in;}@keyframes div{
0%{ color: #001133;}
50%{ color: #001044;}
100%{ color: #000122;}
}

Vendor Prefixing (-*-)

Use the -*- prefix to automatically apply vendor-specific properties across -webkit, -moz, -ms, and -o.

Use Cases

Cross-Browser Transforms
.box {
  -*-transform: rotate(45deg);
}
fscss
.box {
  -*-transform: rotate(45deg);
}
css
.box {
  -webkit-transform: rotate(45deg);
  -moz-transform: rotate(45deg);
  -ms-transform: rotate(45deg);
  -o-transform: rotate(45deg);
}

Function based (@fun)

This guide demonstrates how to use @fun blocks in FSCSS to modularize and reuse style values in your stylesheets. It introduces a cleaner, more maintainable approach to logic-based grouping and referencing in design.

🔧 Functional Blocks in FSCSS

FSCSS enables you to define grouped variables using @fun(variable-name){...}. These can represent sizes, colors, property sets, and more. Reference them anywhere using dot-notation (i.e, @fun.varname.itproperty.value ).

📐 Define Sizes – @fun(e)

@fun(e){
  a: 100px;
  b: 200px;
  c: 300px;
}

Efficiently store reusable measurements like widths, spacing, etc.

  • @fun.e.a.value → 100px
  • @fun.e.c.value → 300px

🎨 Define Color Palette – @fun(col)

@fun(col){
  1: #550066;
  2: #005523;
}

Centralize theming and maintain consistent color usage across your UI.

  • @fun.col.1.value → Dark purple
  • @fun.col.2.value → Forest green

🧱 Define CSS Property Groups – @fun(pr)

@fun(pr){
  border: 2px groove red;
  border-radius: 40px 60px 0 6px;
}

Bundle multiple related CSS properties under a single reusable group.

  • @fun.pr.border.value → 2px groove red
  • @fun.pr.border-radius.value → 40px 60px 0 6px

💡 Apply Styles with Functional Values

Use functional values in actual styles:

body {
  background: @fun.col.1.value;
}

This example sets the background color using a centralized functional value.

🧩 <div> Styling

div {
  background: linear-gradient(@fun.col.1.value, @fun.col.2.value);
  @fun.pr;
  outline: @fun.pr.border.value;
  %2(width, height[:@fun.e.a.value;]);
}

Breakdown:

  • background: Gradient using two predefined colors.
  • @fun.pr: Injects grouped border styles.
  • outline: Applies same border style to outline.
  • %2(...): FSCSS shorthand for multiple property assignment.

🚀 Developer Benefits

  • Modular: Style tokens are centrally defined and managed.
  • Readable: Logic is separated from raw values.
  • Reusable: A single source can be injected into many components.
  • Maintainable: Ideal for design systems and long-term projects.

AD

Array @arr() Method Syntax

The @arr() directive is a powerful array-based syntax for reusable value lists such as delays, colors, or dimensions. It's ideal for staggered animations, theming, and scalable utilities.

🔧 Syntax Overview

@arr(name[ item1, item2, item3, ... ])

Or

@arr name[ item1, item2, item3, ... ]
  • name: The identifier used to reference the array.
  • Items: Can be numbers, strings, colors—any valid CSS value.
  • 1-Indexed: Access begins from index [1], not [0].

✨ Example: Animating with FSCSS 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;
  rotate: 0;
  background: @arr.col[3];
}

@keyframes spin {
  0%   { transform: rotate(0); }
  100% { transform: rotate(360deg); }
}

🧠 How It Works

  • @arr(e[0.1, 2.5, 7]) creates: e[1] = 0.1, e[2] = 2.5, e[3] = 7
  • @arr(col[red, blue, green]) creates: col[1] = red, col[2] = blue, col[3] = green
  • Use values with @arr.name[index]
  • Arrays start at index 1, not 0

🔁 Looping with @arr.name[]

Using @arr.name[] without a specific index creates automatically expanded blocks—perfect for animations, lists, or patterns.

Example:

section :nth-child(@arr.e[]) {
  animation-delay: @arr.e[]s;
}

Compiles to:

section :nth-child(1) { animation-delay: 0.1s; }
section :nth-child(2) { animation-delay: 2.5s; }
section :nth-child(3) { animation-delay: 7s; }

🧩 What You Can Build With It

  • Staggered animations with different delays
  • Repeating sections with changing background colors
  • Themeable components using color palettes
  • Responsive breakpoints via predefined size arrays

⚠️ Important Notes

  • FSCSS arrays are 1-indexed
  • Accessing out-of-bound indexes returns undefined
  • For synced effects, align multiple arrays by matching lengths
  • @arr.name[] inside :nth-child() uses index automatically

✅ Best Practices

  • Name arrays descriptively: colors, delays, breakpoints
  • Check array length if using fixed indexes
  • Use @arr.name[] for dynamic, loop-based styling
  • Use inside :nth-child() for built-in indexing behavior

✅ Final Compiled Output (From Example)

section {
  background: blue;
}

section :nth-child(1) {
  animation: spin 3s linear infinite;
  animation-delay: 0.1s;
  rotate: 0;
  background: green;
}

section :nth-child(2) {
  animation: spin 3s linear infinite;
  animation-delay: 2.5s;
  rotate: 0;
  background: green;
}

section :nth-child(3) {
  animation: spin 3s linear infinite;
  animation-delay: 7s;
  rotate: 0;
  background: green;
}

🔚 Summary

The @arr() directive provides dynamic looping and organized value referencing for scalable styling. Whether it's animations, themes, or UI patterns, FSCSS arrays bring JavaScript-like power into your stylesheets with clean, semantic syntax.

🎲 FSCSS @random() Method

The @random() method lets you apply randomized values to CSS properties, enabling dynamic, ever-changing styles without JavaScript. When used with @arr(), it becomes a powerful tool for clean and reusable random styling.

🔧 Syntax


@random([value1, value2, value3, ...])

Returns a randomly selected value from the array on each stylesheet render.

✨ Example: Randomized Button Style


@arr(e[ @random([lightgreen, yellow, white, skyblue]), 
        #@random([500,009,550]) ]);

.btn {
  padding: 10px 20px;
  margin: 10px;
  background: @arr.e[2];
  color: @arr.e[1];
  border: 2px groove @arr.e[1];
  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.

✅ Use Cases

  • Random button colors or positions
  • Playful or animated UI elements
  • Prototype variations fast

🚀 Benefits

  • Dynamic UI: Refreshing styles each load
  • Reusable: Combine with @arr() arrays
  • No JS Needed: Pure CSS-style logic
  • Clean Syntax: Short, clear, maintainable

🔚 Summary

FSCSS @random() simplifies randomized styling for developers—perfect for adding motion, contrast, or playfulness with zero JavaScript.

Understanding more about the copy() Function

The copy() function in FSCSS is a powerful tool for extracting and reusing parts of string values—very useful for design tokens or list manipulation.

How copy(length, variable) Works

Practical Example

body {
  /* primary-color = #4ff */
  background: #4ff000 copy(4, primary-color);
  color: $primary-color!;
}a { color: $primary-color!; }

span:before { /* copy 'midnightblue' and store it as 'my-darkblue' */ content: "blue or midnightblue copy(-14, my-darkblue)"; border: 2px solid $my-darkblue!; }

Section 1: Extracting from Background Property

Section 2: Reusing the Variable

The variable $primary-color is reused in other selectors, promoting consistency:

a {
  color: $primary-color!;
}

Section 3: Extracting with a Negative Length

Summary and Key Takeaways

@num() – Number Calculations

The @num() method in FSCSS allows inline numeric calculations directly in your stylesheets. You can use it to perform arithmetic operations like num(40 * 2)80, and append units like num(4 * 6)px24px.

🛠️ Use Cases

1. Calculating max-height
selector {
  max-height: num(40 * 4); /* = 160 */
}
2. Mix with @random for dynamic values
fscss
textarea {
  max-height: num(@random([40, 10, 5, 0]) + 50);
}

See the @random method →

📌 Summary

  • Lightweight Calculation: Compute values inline using + - * / operations
  • Supports Units: Works with px, %, and other units
  • Dynamic Pairing: Combine with
    @random✅ 100%,
    @arr✅ 100%,
    @fun values ✅ 100%,
    variables ✅ 90%
    @event ✅ 75%
  • Cleaner Code: No JavaScript needed for math

Detailed Exploration of FSCSS Style Sheet

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

These features collectively aim to address the evolving needs of web developers, especially in contexts where performance and maintainability are critical, such as responsive web design and large-scale applications.

Use Cases and Adoption

Given its focus on efficiency, FSCSS appears particularly suited for projects requiring clean and maintainable CSS structures. This includes:

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:

2023 marked a significant milestone with the addition of the copy() function and the framework’s first public release for testing.

Enhancements continued into 2024, with new functions and improved preprocessor memory, culminating in 2025 with the official npm package release of fscss.

This latest release includes:

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, FSCSS aims to enhance learning and collaboration across developer communities.

You can find tutorials and community support on platforms like:

FSCSS File Structure Overview