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

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.

PrefixBreakpointExample
(none)All sizesflex-col
xs:≥ 576pxxs:flex-row
sm:≥ 768pxsm:col-6
md:≥ 992pxmd:hidden
lg:≥ 1200pxlg:col-3

Text colors #

Format: {color}-text (base / 500 variant) or {color}-text:{variant}

transparent-text black-text white-text gray-text red-text green-text blue-text orange-text
blue-text:50 blue-text:300 blue-text (500) blue-text:700 blue-text:900
ClassCSS
{color}-textcolor: {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}

blue-fill blue-fill:50 blue-fill:300 blue-fill:700 red-fill green-fill orange-fill gray-fill black-fill white-fill
ClassCSS
{color}-fillbackground-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.

blue-border
red-border
green-border
gray-border
blue-border:300
blue-border:700
ClassCSS
{color}-borderborder-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
)
grad-0
grad-1
grad-2
grad-blue-to-grey
ClassCSS
grad-0background: linear-gradient(90deg, #2196F3 0%, grey 100%)
grad-1background: linear-gradient(90deg, grey 0%, #F44336 100%)
grad-2background: radial-gradient(#2196F3, #9E9E9E)
grad-blue-to-greybackground: 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.

ClassApplies when
hover:{color}-textElement is hovered
hover:{color}-fillElement is hovered
hover:{color}-borderElement is hovered
focus:{color}-textElement is focused
active:{color}-fillElement is active (clicked)
hover:grad-{n}Element is hovered

Font family #

Format: ff-{name}

Classfont-familyPreview
ff-baseRoboto, -apple-system, sans-serifThe quick brown fox
ff-sansRoboto, -apple-system, sans-serifThe quick brown fox
ff-serifserifThe quick brown fox
ff-monomonospaceThe quick brown fox

Font size #

Format: fs-{key}

ClassSizePreview
fs-xxs0.625rem (10px)The quick brown fox
fs-xs0.75rem (12px)The quick brown fox
fs-sm0.875rem (14px)The quick brown fox
fs-base16pxThe quick brown fox
fs-lg1.25rem (20px)The quick brown fox
fs-xl1.5rem (24px)The quick brown fox
fs-hg2rem (32px)Heading

Font weight #

Format: fw-{weight}

fw-400 — Regular fw-600 — SemiBold fw-700 — Bold
Classfont-weight
fw-400400
fw-600600
fw-700700

Font style #

Format: fs-{style}

Classfont-stylePreview
fs-normalnormalThe quick brown fox
fs-italicitalicThe quick brown fox
fs-obliqueobliqueThe quick brown fox

Line height #

Format: lh-{key}

Classline-height
lh-00
lh-1 / lh-xs1
lh-base1.375
lh-lg1.5

Also available

ClassCSS
ws-baseword-spacing: .03em
ls-baseletter-spacing: 0

Text utilities #

Responsive — all classes work with screen prefixes.

ClassCSSPreview
text-lefttext-align: leftLeft aligned text
text-centertext-align: centerCenter aligned
text-righttext-align: rightRight aligned
text-lowercasetext-transform: lowercaseLOWER CASE
text-uppercasetext-transform: uppercaseupper case
text-capitalizetext-transform: capitalizecapitalize each word
text-striketext-decoration: line-throughStrikethrough text
text-underlinetext-decoration: underlineUnderlined text
no-decoration / text-no-decorationtext-decoration: noneNo decoration
text-nowrapwhite-space: nowrap
text-wrapwhite-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

ClassCSS
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
p-5
p-10
p-20
pv-10 ph-20

Margin #

Format: m{direction}-{value}. Values: 0, 5, 10, 15, 20, 30, 40, auto

ClassCSS
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-automargin-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.

ClassCSS 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-1
bl-2
bl-3
bl-4

Combined directions with color

bl-1 bb-1
red-border
b-1
green-border
bt-1 bb-1
blue-border
br-1 bb-1
gray-border
bt-3 bl-3
orange-border
bb-3
blue-border
bh-2
red-border
bv-2
green-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%

ClassCSS
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
rad-0
rad-3
rad-5
rad-10
rad-50%

Width & Height #

Width values: 10, 15, 20, 1200, 100% — Height values: 10, 15, 20, 100%, 1

ClassCSS
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

ClassCSS
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

ClassCSS
z--1z-index: -1
z-1z-index: 1
z-2z-index: 2
z-3z-index: 3
z-99z-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)

bs-0
none
bs-1
dp1
bs-2
dp2
bs-3
dp3
bs-4
dp4
bs-5
dp5
bs-card
card
Classbox-shadow
bs-0none
bs-10 1px 3px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.24)
bs-20 3px 6px rgba(0,0,0,.16), 0 3px 6px rgba(0,0,0,.23)
bs-30 10px 20px rgba(0,0,0,.19), 0 6px 6px rgba(0,0,0,.23)
bs-40 14px 28px rgba(0,0,0,.25), 0 10px 10px rgba(0,0,0,.22)
bs-50 19px 38px rgba(0,0,0,.30), 0 15px 12px rgba(0,0,0,.22)
bs-card0 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.

ClassApplies when
hover:bs-{key}Element is hovered
focus:bs-{key}Element is focused
active:bs-{key}Element is active (clicked)
hover:bs-4
hover:bs-card
active:bs-0
<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 #

ClassCSS
flexdisplay: flex
inline-flexdisplay: inline-flex
flex-1flex-6flex: 1flex: 6
flex-autoflex: 1 1 auto
flex-initialflex: 0 1 auto
flex-noneflex: none
flex-2
flex-1
flex-3

Flexbox — Direction #

ClassCSS
flex-rowflex-direction: row
flex-row-reverseflex-direction: row-reverse
flex-colflex-direction: column
flex-col-reverseflex-direction: column-reverse
item 1
item 2
item 3

Example: flex flex-col

Flexbox — Wrap #

ClassCSS
flex-wrapflex-wrap: wrap
flex-wrap-reverseflex-wrap: wrap-reverse
flex-nowrapflex-wrap: nowrap

Flexbox — Grow & Shrink #

ClassCSS
growflex-grow: 1
grow-0flex-grow: 0
shrinkflex-shrink: 1
shrink-0flex-shrink: 0
shrink-0
grow

Flexbox — Basis #

ClassCSS
basis-autoflex-basis: auto
basis-fullflex-basis: 100%
basis-0flex-basis: 0

Flexbox — Justify content #

Classjustify-content
justify-startflex-start
justify-endflex-end
justify-centercenter
justify-betweenspace-between
justify-aroundspace-around
justify-evenlyspace-evenly
A
B
C

Example: flex justify-between

A
B
C

Example: flex justify-center

Flexbox — Align items #

Classalign-items
items-startflex-start
items-endflex-end
items-centercenter
items-baselinebaseline
items-stretchstretch
A
B (tall)
C

Example: flex items-center

Flexbox — Align content #

Used with multi-line flex containers (flex-wrap).

Classalign-content
content-startflex-start
content-endflex-end
content-centercenter
content-betweenspace-between
content-aroundspace-around
content-evenlyspace-evenly
content-stretchstretch

Flexbox — Align self #

Applied to an individual flex child to override the parent's align-items.

Classalign-self
self-autoauto
self-startflex-start
self-endflex-end
self-centercenter
self-baselinebaseline
self-stretchstretch
self-start
self-center
self-end

Flexbox — Order #

Classorder
order-first-9999
order-last9999
order-none0
order-1order-121 … 12
order-3 (DOM 1st)
order-1 (DOM 2nd)
order-2 (DOM 3rd)

Flexbox — Shorthand helpers #

Convenience classes that combine display + alignment in one.

ClassCSS
flex-centerdisplay:flex; align-items:center; justify-content:center
flex-betweendisplay:flex; align-items:center; justify-content:space-between
flex-col-centerdisplay:flex; flex-direction:column; align-items:center; justify-content:center
flex-center
leftright
colcenter

Grid — Container #

ClassCSS
containerCentered block, max-width shrinks to the current breakpoint width minus gutter, with horizontal gutter padding
container-fluidFull-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 #

ClassCSS
rowdisplay:flex; flex-wrap:wrap + negative gutter margins
row-reverseApplies flex-direction: row-reverse inside a .row
col-reverseApplies flex-direction: column-reverse on a column

Grid — Columns #

12-column grid. Responsive: prefix with xs:, sm:, md:, lg:.

col-12
col-6
col-6
col-4
col-4
col-4
col-3
col-3
col-3
col-3
col-8
col-4
col (auto)
col (auto)
col (auto)

<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 #

ClassCSS
col-{n}-offsetmargin-left: {n/12 * 100}%
col-{n}-pushleft: {n/12 * 100}%
col-{n}-pullright: {n/12 * 100}%
col-6 col-3-offset

Grid — Row utilities #

Applied to a .row element to control alignment of its columns.

ClassCSS
items-startjustify-content: flex-start
items-endjustify-content: flex-end
items-centerjustify-content: center
items-aroundjustify-content: space-around
items-betweenjustify-content: space-between
items-topalign-items: flex-start
items-middlealign-items: center
items-bottomalign-items: flex-end
items-reverseflex-direction: row-reverse

Utilities — Display #

All are responsive.

ClassCSS
block / showdisplay: block
hidden / hidedisplay: none
inlinedisplay: inline
inline-blockdisplay: inline-block
tabledisplay: table
table-rowdisplay: table-row
table-celldisplay: table-cell
flexdisplay: flex
inline-flexdisplay: inline-flex
visiblevisibility: visible
invisiblevisibility: hidden

Utilities — Position #

All are responsive.

ClassCSS
relativeposition: relative
absoluteposition: absolute
fixedposition: fixed
staticposition: static
stickyposition: sticky

Utilities — Overflow #

ClassCSS
of-hiddenoverflow: hidden
of-visibleoverflow: visible
of-autooverflow: auto
of-auto-yoverflow-y: auto
of-auto-xoverflow-x: auto
of-scrolloverflow: scroll
of-scroll-yoverflow-y: scroll
of-scroll-xoverflow-x: scroll

Utilities — Float & Clear #

ClassCSS
float-leftfloat: left
float-rightfloat: right
float-nonefloat: none
clear-leftclear: left
clear-rightclear: right
clear-bothclear: both
clear-noneclear: none
clearfix::before + ::after clearfix hack

Utilities — Vertical align #

Format: va-{value}

Classvertical-align
va-initialinitial
va-inheritinherit
va-middlemiddle
va-supersuper
va-subsub
va-toptop
va-bottombottom
va-text-toptext-top
va-text-bottomtext-bottom

Utilities — Group #

A horizontal flexbox row with no-shrink children. Useful for button groups, navbars, etc.

ClassRole
groupFlex container: display:flex; flex-direction:row
group-itemNon-shrinking child: flex-shrink:0
group-item-shrinkShrinkable child override
group-shrinkMakes all children shrinkable
group-verticalflex-direction: column
group-centerjustify-content: center
group-leftjustify-content: flex-start
group-rightjustify-content: flex-end
group-item
group-item
group-item-shrink grow

Utilities — List #

ClassCSS
list-nonelist-style-type: none
list-disclist-style-type: disc
list-circlelist-style-type: circle
list-squarelist-style-type: square
list-decimallist-style-type: decimal
list-upper-romanlist-style-type: upper-roman
list-lower-romanlist-style-type: lower-roman
list-upper-latinlist-style-type: upper-latin
list-lower-latinlist-style-type: lower-latin
list-outsidelist-style-position: outside
list-insidelist-style-position: inside
  • list-disc
  • item
  • item
  • list-decimal
  • item
  • item
  • list-none
  • no bullets
  • here

Utilities — Cursor #

Format: cursor-{value}

Classcursor
cursor-defaultdefault
cursor-nonenone
cursor-grabgrab
cursor-grabbinggrabbing
cursor-helphelp
cursor-pointerpointer
cursor-zoom-inzoom-in
cursor-zoom-outzoom-out
cursor-pointer (hover me) cursor-help cursor-grab cursor-zoom-in

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}

StatesTargetsDisplays
hover, focus, activechild (→ > *), sibling (→ ~ *)block, flex, inline, inline-block, grid, hide

Examples

ClassEffect
hover:child-blockOn hover, sets display:block on all direct children
hover:child-hideOn hover, hides all direct children
hover:sibling-flexOn hover, sets display:flex on all siblings
focus:child-blockOn focus, shows all direct children as block

Live examples

hover:child-block

Hover me
<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

Click me Child hidden on click
<div class="active:child-hide">
  <span>Click me</span>
  <span>Hidden on click</span>
</div>

hover:child-flex

Hover card to reveal actions
<div class="hover:child-flex">
  Card content
  <div style="display:none">
    <!-- action buttons -->
  </div>
</div>

hover:sibling-block

Hover for tooltip
<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>