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(-14, my-darkblue)";
          border: 2px solid $my-darkblue!;
         } 

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;
}

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);
}

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:

FSCSS File Structure Overview