Fastcss — Config-driven SASS/SCSS Utility CSS Framework
What is fastcss #
A fully customizable, pure-SASS utility CSS framework. Generate only the classes you need from a single config map.
Fastcss generates helper classes at build time from a SASS $config map. The config controls colors, spacing scale, screen breakpoints, typography and more — so the final CSS only contains what you actually configured.
Installation #
npm / yarn
npm install fastcss # or yarn add fastcss
Import in your SCSS
// Use default config @use 'fastcss'; // Or supply your own config @use 'fastcss' with ($config: $myConfig);
Compile
sass scss/build.scss dist/fastcss.css
Configuration #
All of fastcss is driven by a single $config Sass map. Copy node_modules/fastcss/scss/_config.scss into your project, trim it down to only what you need, and pass it to fastcss at compile time. Every value you add generates more CSS — keep the config lean and your output file will stay small.
Minimal config example
// _my-config.scss
$defaultConfig: (
// ─── Typography ────────────────────────────────────────────────
// Each key in font-size generates .fs-{key}, each weight generates .fw-{weight}.
// More values = more classes = bigger file.
'typography': (
'font-family': (
'base': "Roboto, -apple-system, sans-serif",
'mono': monospace,
),
'font-size': (
'sm': .875rem, // → .fs-sm
'base': 1rem, // → .fs-base
'lg': 1.25rem, // → .fs-lg
'xl': 1.5rem, // → .fs-xl
),
'font-weight': (400, 600, 700), // → .fw-400 .fw-600 .fw-700
'font-style': (normal, italic),
'line-height': (
'base': 1.5, // → .lh-base
),
),
// ─── Box / Spacing ─────────────────────────────────────────────
// padding and margin lists are the actual values. stripunits:true removes
// the px suffix from class names (e.g. p-10 instead of p-10px).
'box': (
'stripunits': true,
'padding': (0, 5px, 10px, 15px, 20px), // → .p-0 .p-5 .p-10 …
'margin': (0, auto, 5px, 10px, 20px), // → .m-0 .m-auto .m-5 …
'width': (100%, 200px, 400px), // → .w-100\% .w-200 …
'height': (100%, 40px),
'positions': (0, 5px, 10px), // top/right/bottom/left helpers
'z-index': (1, 2, 99),
'border-radius':(0, 4px, 50%), // → .rad-0 .rad-4 .rad-50\%
'border-width': (0, 1px, 2px), // → .b-0 .b-1 .b-2
// Named or numeric keys — key becomes the class suffix: bs-{key}
// Add a named key for semantic aliases: hover:bs-card
'shadow': (
'0': "none",
'1': "0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24)",
'2': "0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23)",
'card': "0 2px 8px rgba(0,0,0,0.10), 0 1px 3px rgba(0,0,0,0.08)",
),
),
// ─── Grid ──────────────────────────────────────────────────────
// columns: number of grid columns.
// screens: each breakpoint doubles the class count for every utility.
// Remove breakpoints you don't need to reduce output size significantly.
'grid': (
'columns': 12,
'gutter': 30px,
'utilities': true,
'screens': (
'xs': 576px,
'sm': 768px,
'md': 992px,
'lg': 1200px,
),
),
// ─── Colors ────────────────────────────────────────────────────
// Format: 'name:variant1,variant2,...': #baseHex
// Each variant generates .name-text:variant, .name-fill:variant, .name-border:variant
// plus all their responsive and state variants → colors are the biggest CSS cost.
//
// Omit variants to generate only the base (500): 'white': #fff
'colors': (
'palette': (
'transparent': transparent,
'white': #FFFFFF,
'black': #000000,
'gray:300,500,700': #9E9E9E, // → .gray-text:300 .gray-fill:500 …
'blue:100,300,500,700,900': #2196F3, // → .blue-text .blue-fill .blue-border …
'red:300,500,700': #F44336,
),
// Lightness/darkness adjustment per variant (positive = lighter, negative = darker)
'variants': (
'100': 70,
'300': 30,
'500': 0, // base — no adjustment
'700': -21,
'900': -52.5,
),
// Named or numeric gradient keys → grad-{key}
'gradients': (
'0': linear-gradient(90deg, #2196F3, #9E9E9E),
'blue-fade': linear-gradient(180deg, #2196F3 0%, transparent 100%),
),
),
// ─── Utilities ─────────────────────────────────────────────────
'utilities': (
'cursor': ('pointer', 'default', 'grab', 'grabbing'),
'text-decoration': ('none', 'underline', 'line-through'),
'vertical-align': ('middle', 'top', 'bottom'),
'list-style-type': ('none', 'disc', 'decimal'),
),
);
How to use your config
// main.scss @use 'my-config' as *; // exposes $defaultConfig @use 'fastcss' with ($config: $defaultConfig);
Responsive prefixes #
Almost every utility class is generated for each breakpoint defined in grid.screens. Prefix a class with {screen}: to apply it only at that breakpoint and above.
| Prefix | Breakpoint | Example |
|---|---|---|
| (none) | All sizes | flex-col |
xs: | ≥ 576px | xs:flex-row |
sm: | ≥ 768px | sm:col-6 |
md: | ≥ 992px | md:hidden |
lg: | ≥ 1200px | lg:col-3 |
Text colors #
Format: {color}-text (base / 500 variant) or {color}-text:{variant}
| Class | CSS |
|---|---|
{color}-text | color: {hex} — base (500) variant |
{color}-text:{variant} | color: {computed hex} |
| Variants: 50, 100, 200, 300, 400, 500, 600, 700, 800, 900 (only configured variants are generated per color) | |
Fill (background) #
Format: {color}-fill or {color}-fill:{variant}
| Class | CSS |
|---|---|
{color}-fill | background-color: {hex} — base (500) variant |
{color}-fill:{variant} | background-color: {computed hex} |
Border colors #
Format: {color}-border or {color}-border:{variant}. Requires a border-width class (e.g. b-1) to be visible.
| Class | CSS |
|---|---|
{color}-border | border-color: {hex} |
{color}-border:{variant} | border-color: {computed hex} |
Note: [class*="-border"] also sets border-style: solid; border-width: 0 automatically. | |
Gradients #
Format: grad-{key} — the key is defined in colors.gradients config. Use numeric keys for backwards compatibility and named keys for readability.
'gradients': ( '0': linear-gradient(...), // → .grad-0 'blue-to-grey': radial-gradient(...), // → .grad-blue-to-grey )
| Class | CSS |
|---|---|
grad-0 | background: linear-gradient(90deg, #2196F3 0%, grey 100%) |
grad-1 | background: linear-gradient(90deg, grey 0%, #F44336 100%) |
grad-2 | background: radial-gradient(#2196F3, #9E9E9E) |
grad-blue-to-grey | background: radial-gradient(#2196F3, #9E9E9E) |
State variants are also generated: hover:grad-0, hover:grad-blue-to-grey, etc.
Color state variants #
All color classes (text, fill, border, gradients) are also generated for hover:, focus:, and active: states.
| Class | Applies when |
|---|---|
hover:{color}-text | Element is hovered |
hover:{color}-fill | Element is hovered |
hover:{color}-border | Element is hovered |
focus:{color}-text | Element is focused |
active:{color}-fill | Element is active (clicked) |
hover:grad-{n} | Element is hovered |
Font family #
Format: ff-{name}
| Class | font-family | Preview |
|---|---|---|
ff-base | Roboto, -apple-system, sans-serif | The quick brown fox |
ff-sans | Roboto, -apple-system, sans-serif | The quick brown fox |
ff-serif | serif | The quick brown fox |
ff-mono | monospace | The quick brown fox |
Font size #
Format: fs-{key}
| Class | Size | Preview |
|---|---|---|
fs-xxs | 0.625rem (10px) | The quick brown fox |
fs-xs | 0.75rem (12px) | The quick brown fox |
fs-sm | 0.875rem (14px) | The quick brown fox |
fs-base | 16px | The quick brown fox |
fs-lg | 1.25rem (20px) | The quick brown fox |
fs-xl | 1.5rem (24px) | The quick brown fox |
fs-hg | 2rem (32px) | Heading |
Font weight #
Format: fw-{weight}
| Class | font-weight |
|---|---|
fw-400 | 400 |
fw-600 | 600 |
fw-700 | 700 |
Font style #
Format: fs-{style}
| Class | font-style | Preview |
|---|---|---|
fs-normal | normal | The quick brown fox |
fs-italic | italic | The quick brown fox |
fs-oblique | oblique | The quick brown fox |
Line height #
Format: lh-{key}
| Class | line-height |
|---|---|
lh-0 | 0 |
lh-1 / lh-xs | 1 |
lh-base | 1.375 |
lh-lg | 1.5 |
Also available
| Class | CSS |
|---|---|
ws-base | word-spacing: .03em |
ls-base | letter-spacing: 0 |
Text utilities #
Responsive — all classes work with screen prefixes.
| Class | CSS | Preview |
|---|---|---|
text-left | text-align: left | Left aligned text |
text-center | text-align: center | Center aligned |
text-right | text-align: right | Right aligned |
text-lowercase | text-transform: lowercase | LOWER CASE |
text-uppercase | text-transform: uppercase | upper case |
text-capitalize | text-transform: capitalize | capitalize each word |
text-strike | text-decoration: line-through | Strikethrough text |
text-underline | text-decoration: underline | Underlined text |
no-decoration / text-no-decoration | text-decoration: none | No decoration |
text-nowrap | white-space: nowrap | — |
text-wrap | white-space: wrap | — |
State variants available: hover:text-strike, hover:text-underline, hover:no-decoration
Padding #
Format: {direction}-{value}. Values from config: 0, 1, 2, 3, 4, 5, 10, 15, 20
| Class | CSS |
|---|---|
p-{n} | padding: {n}px |
pt-{n} | padding-top: {n}px |
pr-{n} | padding-right: {n}px |
pb-{n} | padding-bottom: {n}px |
pl-{n} | padding-left: {n}px |
pv-{n} | padding-top + padding-bottom: {n}px |
ph-{n} | padding-left + padding-right: {n}px |
Margin #
Format: m{direction}-{value}. Values: 0, 5, 10, 15, 20, 30, 40, auto
| Class | CSS |
|---|---|
m-{n} | margin: {n}px |
mt-{n} | margin-top: {n}px |
mr-{n} | margin-right: {n}px |
mb-{n} | margin-bottom: {n}px |
ml-{n} | margin-left: {n}px |
mv-{n} | margin-top + margin-bottom: {n}px |
mh-{n} | margin-left + margin-right: {n}px |
mh-auto | margin-left: auto; margin-right: auto — center block |
Border width #
Format: b{direction}-{value}. Values: 0, 1, 2, 3, 4. Combine with a {color}-border class to set the color — border-style is set automatically.
| Class | CSS property |
|---|---|
b-{n} | border-width — all sides |
bt-{n} | border-top-width |
br-{n} | border-right-width |
bb-{n} | border-bottom-width |
bl-{n} | border-left-width |
bv-{n} | border-top-width + border-bottom-width — vertical |
bh-{n} | border-left-width + border-right-width — horizontal |
Directions
bt-2
br-2
bb-2
bl-2
bv-2
bh-2
b-2
b-0
Widths
bl-1bl-2bl-3bl-4Combined directions with color
bl-1 bb-1red-border
b-1green-border
bt-1 bb-1blue-border
br-1 bb-1gray-border
bt-3 bl-3orange-border
bb-3blue-border
bh-2red-border
bv-2green-border
All border classes also work with responsive prefixes: sm:bl-2, md:b-0, etc.
Border radius #
Format: rad-{value}. Values: 0, 3, 5, 10, 50%
| Class | CSS |
|---|---|
rad-{n} | border-radius: {n}px |
radtl-{n} | border-top-left-radius: {n}px |
radtr-{n} | border-top-right-radius: {n}px |
radbl-{n} | border-bottom-left-radius: {n}px |
radbr-{n} | border-bottom-right-radius: {n}px |
Width & Height #
Width values: 10, 15, 20, 1200, 100% — Height values: 10, 15, 20, 100%, 1
| Class | CSS |
|---|---|
w-{n} | width: {n}px |
minw-{n} | min-width: {n}px |
maxw-{n} | max-width: {n}px |
w-100\% | width: 100% |
h-{n} | height: {n}px |
minh-{n} | min-height: {n}px |
maxh-{n} | max-height: {n}px |
h-100\% | height: 100% |
Positions #
Used with absolute / fixed / sticky. Values: 0, 5, 10, 15
| Class | CSS |
|---|---|
top-{n} | top: {n}px |
right-{n} | right: {n}px |
bottom-{n} | bottom: {n}px |
left-{n} | left: {n}px |
Z-index #
Format: z-{value}. Values: -1, 1, 2, 3, 99
| Class | CSS |
|---|---|
z--1 | z-index: -1 |
z-1 | z-index: 1 |
z-2 | z-index: 2 |
z-3 | z-index: 3 |
z-99 | z-index: 99 |
Box shadow #
Format: bs-{key} — the key is defined in box.shadow config. Use numeric keys for backwards compatibility and named keys for readability.
'shadow': ( '0': "none", // → .bs-0 '1': "0 1px 3px rgba(0,0,0,0.12)...", // → .bs-1 'card': "0 2px 8px rgba(0,0,0,0.12)...", // → .bs-card )
Material scale (bs-0 → bs-5)
none
dp1
dp2
dp3
dp4
dp5
card
| Class | box-shadow |
|---|---|
bs-0 | none |
bs-1 | 0 1px 3px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.24) |
bs-2 | 0 3px 6px rgba(0,0,0,.16), 0 3px 6px rgba(0,0,0,.23) |
bs-3 | 0 10px 20px rgba(0,0,0,.19), 0 6px 6px rgba(0,0,0,.23) |
bs-4 | 0 14px 28px rgba(0,0,0,.25), 0 10px 10px rgba(0,0,0,.22) |
bs-5 | 0 19px 38px rgba(0,0,0,.30), 0 15px 12px rgba(0,0,0,.22) |
bs-card | 0 2px 8px rgba(0,0,0,.12), 0 1px 3px rgba(0,0,0,.08) |
State variants
Every shadow class is also generated for hover:, focus:, and active: states. Useful for interactive elements like cards and buttons.
| Class | Applies when |
|---|---|
hover:bs-{key} | Element is hovered |
focus:bs-{key} | Element is focused |
active:bs-{key} | Element is active (clicked) |
<div class="bs-1 hover:bs-4">Card</div> <div class="bs-0 hover:bs-card">Flat card</div> <button class="bs-2 active:bs-0">Button</button>
Add any key to box.shadow in your config to generate a new bs-{key} class with state variants automatically included.
Flexbox — Display #
| Class | CSS |
|---|---|
flex | display: flex |
inline-flex | display: inline-flex |
flex-1 … flex-6 | flex: 1 … flex: 6 |
flex-auto | flex: 1 1 auto |
flex-initial | flex: 0 1 auto |
flex-none | flex: none |
Flexbox — Direction #
| Class | CSS |
|---|---|
flex-row | flex-direction: row |
flex-row-reverse | flex-direction: row-reverse |
flex-col | flex-direction: column |
flex-col-reverse | flex-direction: column-reverse |
Example: flex flex-col
Flexbox — Wrap #
| Class | CSS |
|---|---|
flex-wrap | flex-wrap: wrap |
flex-wrap-reverse | flex-wrap: wrap-reverse |
flex-nowrap | flex-wrap: nowrap |
Flexbox — Grow & Shrink #
| Class | CSS |
|---|---|
grow | flex-grow: 1 |
grow-0 | flex-grow: 0 |
shrink | flex-shrink: 1 |
shrink-0 | flex-shrink: 0 |
Flexbox — Basis #
| Class | CSS |
|---|---|
basis-auto | flex-basis: auto |
basis-full | flex-basis: 100% |
basis-0 | flex-basis: 0 |
Flexbox — Justify content #
| Class | justify-content |
|---|---|
justify-start | flex-start |
justify-end | flex-end |
justify-center | center |
justify-between | space-between |
justify-around | space-around |
justify-evenly | space-evenly |
Example: flex justify-between
Example: flex justify-center
Flexbox — Align items #
| Class | align-items |
|---|---|
items-start | flex-start |
items-end | flex-end |
items-center | center |
items-baseline | baseline |
items-stretch | stretch |
Example: flex items-center
Flexbox — Align content #
Used with multi-line flex containers (flex-wrap).
| Class | align-content |
|---|---|
content-start | flex-start |
content-end | flex-end |
content-center | center |
content-between | space-between |
content-around | space-around |
content-evenly | space-evenly |
content-stretch | stretch |
Flexbox — Align self #
Applied to an individual flex child to override the parent's align-items.
| Class | align-self |
|---|---|
self-auto | auto |
self-start | flex-start |
self-end | flex-end |
self-center | center |
self-baseline | baseline |
self-stretch | stretch |
Flexbox — Order #
| Class | order |
|---|---|
order-first | -9999 |
order-last | 9999 |
order-none | 0 |
order-1 … order-12 | 1 … 12 |
Flexbox — Shorthand helpers #
Convenience classes that combine display + alignment in one.
| Class | CSS |
|---|---|
flex-center | display:flex; align-items:center; justify-content:center |
flex-between | display:flex; align-items:center; justify-content:space-between |
flex-col-center | display:flex; flex-direction:column; align-items:center; justify-content:center |
Grid — Container #
| Class | CSS |
|---|---|
container | Centered block, max-width shrinks to the current breakpoint width minus gutter, with horizontal gutter padding |
container-fluid | Full-width block, horizontal gutter padding only — no max-width |
container
Centered, max-width constrained per breakpoint. Resize the window to see it adapt.
<div class="container">
<div class="row">
<div class="xs:col-12 sm:col-3 md:col-2 lg:col-1">...</div>
<div class="xs:col-6 sm:col-6 md:col-8 lg:col-10">...</div>
<div class="xs:col-6 sm:col-3 md:col-2 lg:col-1">...</div>
</div>
</div>
container-fluid
Always stretches to full width, only adds gutter padding on the sides.
<div class="container-fluid">
<div class="row">
<div class="xs:col-10 sm:col-6 md:col-8 lg:col-10">...</div>
<div class="xs:col-2 sm:col-6 md:col-4 lg:col-2">...</div>
</div>
</div>
Grid — Row #
| Class | CSS |
|---|---|
row | display:flex; flex-wrap:wrap + negative gutter margins |
row-reverse | Applies flex-direction: row-reverse inside a .row |
col-reverse | Applies flex-direction: column-reverse on a column |
Grid — Columns #
12-column grid. Responsive: prefix with xs:, sm:, md:, lg:.
<div class="row"> <div class="col-12 sm:col-6 md:col-4 lg:col-3">...</div> <div class="col-12 sm:col-6 md:col-8 lg:col-9">...</div> </div>
Grid — Offset, Push, Pull #
| Class | CSS |
|---|---|
col-{n}-offset | margin-left: {n/12 * 100}% |
col-{n}-push | left: {n/12 * 100}% |
col-{n}-pull | right: {n/12 * 100}% |
Grid — Row utilities #
Applied to a .row element to control alignment of its columns.
| Class | CSS |
|---|---|
items-start | justify-content: flex-start |
items-end | justify-content: flex-end |
items-center | justify-content: center |
items-around | justify-content: space-around |
items-between | justify-content: space-between |
items-top | align-items: flex-start |
items-middle | align-items: center |
items-bottom | align-items: flex-end |
items-reverse | flex-direction: row-reverse |
Utilities — Display #
All are responsive.
| Class | CSS |
|---|---|
block / show | display: block |
hidden / hide | display: none |
inline | display: inline |
inline-block | display: inline-block |
table | display: table |
table-row | display: table-row |
table-cell | display: table-cell |
flex | display: flex |
inline-flex | display: inline-flex |
visible | visibility: visible |
invisible | visibility: hidden |
Utilities — Position #
All are responsive.
| Class | CSS |
|---|---|
relative | position: relative |
absolute | position: absolute |
fixed | position: fixed |
static | position: static |
sticky | position: sticky |
Utilities — Overflow #
| Class | CSS |
|---|---|
of-hidden | overflow: hidden |
of-visible | overflow: visible |
of-auto | overflow: auto |
of-auto-y | overflow-y: auto |
of-auto-x | overflow-x: auto |
of-scroll | overflow: scroll |
of-scroll-y | overflow-y: scroll |
of-scroll-x | overflow-x: scroll |
Utilities — Float & Clear #
| Class | CSS |
|---|---|
float-left | float: left |
float-right | float: right |
float-none | float: none |
clear-left | clear: left |
clear-right | clear: right |
clear-both | clear: both |
clear-none | clear: none |
clearfix | ::before + ::after clearfix hack |
Utilities — Vertical align #
Format: va-{value}
| Class | vertical-align |
|---|---|
va-initial | initial |
va-inherit | inherit |
va-middle | middle |
va-super | super |
va-sub | sub |
va-top | top |
va-bottom | bottom |
va-text-top | text-top |
va-text-bottom | text-bottom |
Utilities — Group #
A horizontal flexbox row with no-shrink children. Useful for button groups, navbars, etc.
| Class | Role |
|---|---|
group | Flex container: display:flex; flex-direction:row |
group-item | Non-shrinking child: flex-shrink:0 |
group-item-shrink | Shrinkable child override |
group-shrink | Makes all children shrinkable |
group-vertical | flex-direction: column |
group-center | justify-content: center |
group-left | justify-content: flex-start |
group-right | justify-content: flex-end |
Utilities — List #
| Class | CSS |
|---|---|
list-none | list-style-type: none |
list-disc | list-style-type: disc |
list-circle | list-style-type: circle |
list-square | list-style-type: square |
list-decimal | list-style-type: decimal |
list-upper-roman | list-style-type: upper-roman |
list-lower-roman | list-style-type: lower-roman |
list-upper-latin | list-style-type: upper-latin |
list-lower-latin | list-style-type: lower-latin |
list-outside | list-style-position: outside |
list-inside | list-style-position: inside |
- list-disc
- item
- item
- list-decimal
- item
- item
- list-none
- no bullets
- here
Utilities — Cursor #
Format: cursor-{value}
| Class | cursor |
|---|---|
cursor-default | default |
cursor-none | none |
cursor-grab | grab |
cursor-grabbing | grabbing |
cursor-help | help |
cursor-pointer | pointer |
cursor-zoom-in | zoom-in |
cursor-zoom-out | zoom-out |
Utilities — State child/sibling toggles #
Toggle the display of all direct children or all siblings when the element enters a state.
Format: {state}:{target}-{display}
| States | Targets | Displays |
|---|---|---|
hover, focus, active | child (→ > *), sibling (→ ~ *) | block, flex, inline, inline-block, grid, hide |
Examples
| Class | Effect |
|---|---|
hover:child-block | On hover, sets display:block on all direct children |
hover:child-hide | On hover, hides all direct children |
hover:sibling-flex | On hover, sets display:flex on all siblings |
focus:child-block | On focus, shows all direct children as block |
Live examples
hover:child-block
<div class="hover:child-block">
Hover me
<div style="display:none">
Child visible on hover
</div>
</div>
focus:sibling-flex
<input class="focus:sibling-flex" /> <div style="display:none"> Sibling appears on focus </div>
active:child-hide
<div class="active:child-hide"> <span>Click me</span> <span>Hidden on click</span> </div>
hover:child-flex
<div class="hover:child-flex">
Card content
<div style="display:none">
<!-- action buttons -->
</div>
</div>
hover:sibling-block
<span class="hover:sibling-block"> Hover for tooltip </span> <div style="display:none"> Sibling tooltip </div>
active:sibling-flex
<button class="active:sibling-flex"> Press me </button> <div style="display:none"> Shown while pressed </div>