“Everything should be made as simple as possible, but no simpler.” – Albert Einstein 1
Quantum CSS is an atomic CSS library written in SCSS.
You won’t need to write any CSS rules and media queries while using Quantum CSS. Creating highly responsive UIs becomes pleasure while extension pattern provides means of controlled customization. You can create molecules with avaialble atoms using @extend.
Here is a sample button component with rounded corners, hover and focus transition animations (which are disabled on small screens to provide better experience on touch devices):
<button class="btn btn-fb" type="button">
<!-- Content -->
</button>.btn {
@extend .px15, .h40; // Size
@extend .bds-s, .bdw1, .bdr5; // Border style solid, border width 1px and rounded corners
@extend .trp-c, .trd200ms; // Color transitions
&-fb { @extend .bgc-fb, .c-w, .bdc-tt, .SM_bgc-dfb-hf } // Facebook
&-tw { @extend .bgc-tw, .c-w, .bdc-tt, .SM_bgc-dtw-hf } // Twitter
}Benefits of using @extend approach:
-
Highly standardized styles. Limited amount of building blocks allows you to have more order in your design.
-
Stylesheet compilation time errors. Build fails if unknown atoms are used.
-
Easy to remember class names. Atoms naming convention was heavily inspired by Emmet, and most of the time abbreviations are first letters of words that property or value names consist of.
-
Background
background-color
background-attachment
background-clip
background-image
background-origin
background-repeat
background-sizebackground-position
background-position-x
background-position-y -
Border
border-color
border-top-color
border-right-color
border-bottom-color
border-left-colorborder-width
border-top-width
border-right-width
border-bottom-width
border-left-widthborder-style
border-top-style
border-right-style
border-bottom-style
border-left-styleborder-radius
border-top-right-radius
border-top-left-radius
border-bottom-right-radius
border-bottom-left-radius -
Flexible Box Layout
flex-direction
flex-wrap
flex-grow
flex-shrink
flex-basis
justify-content
align-items
align-content
align-self
order -
Positioning
float
clear
position
top
right
bottom
left
z-index -
Fonts
font-size
line-height
font-family
font-weight
font-style
font-variant
font-size-adjust
font-stretch
-webkit-font-smoothing
-moz-osx-font-smoothing -
Transitions
transition-property
transition-duration
transition-timing-function -
Text
letter-spacing
overflow-wrap
text-align
text-align-last
text-indent
text-decoration
text-transform
white-space
word-break
word-wrap -
Lists and Counters
list-style
list-style-position
list-style-type -
Box Model
box-sizing
height
width
margin
padding
overflow
overflow-x
overflow-y
-webkit-overflow-scrolling
visibility -
Table
border-collapse
caption-side
empty-cells
table-layout
vertical-align
In Quantum CSS every class name consists of four parts in given order:
- Optional breakpoint name:
SM,MDetc. - Property abbreviation:
bdtc,wsetc. - Value abbreviation:
w,100p,360detc. - Optional pseudo-class or pseudo-element modifier:
hf,hetc.
You can configure separators between each parts of class name with following variables:
-
$breakpoint-sepdefine separator between breakpoint name and property abbreviation. -
$literal-sepand$ordinal-sepdefine separators that are inserted between property name and literal value abbreviation or ordinal one respectively. -
$pseudo-sepdefines separator between pseudo modifier from value abbreviation.
Aliases for commonly used values:
p→%e→emx→exr→remd→degt→turn
These aliases are used instead of full units:
Names for colors are used fo increase readability. By default, Tango palette is used for every color-related atom. You can specify your own palette overriding variables in _variables.scss.
| Greyscale | Value |
|---|
- White
w|#fff - Grey 15%
g1|#eeeeec - Grey 30%
g2|#d3d7cf - Grey 45%
g3|#babdb6 - Grey 60%
g4|#888a85 - Grey 75%
g5|#555753 - Grey 90%
g6|#2e3436 - Black
b|#000
| Color | Light l |
Medium | Dark d |
|---|
- Yellow
y|#fce94f|#edd400|#c4a000 - Orange
o|#fcaf3e|#f57900|#ce5c00 - Chocolate
c|#e9b96e|#c17d11|#8f5902 - Green
g|#8ae234|#73d216|#4e9a06 - Navy
n|#729fcf|#3465a4|#204a87 - Purple
p|#ad7f8a|#75507b|#5c3566 - Red
r|#ef2929|#cc0000|#a40000
CSS-literal colors:
cc→currentColort→transparenti→inherit
Generated atom examples:
SM_bgc-dg→background-color: #4e9a06Dark greenbdrc-w→border-right-color: whiteLG_c-b→color: black
Some CSS properties are defined as unit-less, e.g. no unit suffix will be outputted:
One of the most powerful features of Quantum is breakpoint-based media queries.
You can configure set of pseudo-classes and pseudo-elements for which atoms are generated via $pseudos. To emit disjunction of pseudos use comma-separated list.
$pseudos: (hf: (hover, focus));
.c-w-hf:hover,
.c-w-hf:focus {
color: white;
}Space-separated list defines selector conjunction:
$pseudos: (eh: empty hover);
.c-w-eh:empty:hover {
color: white;
}Combine those different list types for precise class targeting:
$pseudos: (foo: (active hover, active focus));
.c-w-foo:active:hover,
.c-w-foo:active:focus {
color: white;
}As well as in Bootstrap Containers are the most basic layout element and are required when using grid system. Use g-f to create a fixed-width centered responsive layout of columns.
While containers can be nested, most layouts do not require a nested container.
<div class="g g-f">
<!-- Fixed-width grid conteiner -->
</div>Widths of fixed-width container are stored in $grid-widths.
Rows are horizontal groups of columns that ensure your columns are lined up properly.
<div class="g g-f">
<div class="gr">
<!-- Place columns here -->
</div>
</div>Content should be placed within columns, and only columns may be immediate children of rows.
Column classes indicate the number of columns you’d like to use out of the possible 12 per row. So if you want three equal-width columns, you’d use SM_gc4. You can change number of columns in grid altering $grid-col-count.
Column widths are set in percentages, so they’re always fluid and sized relative to their parent element.
Columns have horizontal padding to create the gutters between individual columns. Gutters can be configured per every breakpoint via $grid-gutters.
<div class="g g-f">
<div class="gr">
<div class="gc12 SM_gc6">
<!-- Place content here -->
</div>
</div>
</div>In addition to column clearing at responsive breakpoints, you may need to reset offsets, pushes, or pulls.
Move columns to the right using [breakpoint_]go(0…12/1) classes. These classes increase the left margin of a column by specified number of columns. For example, MD_go4 moved MD_gc4 over four columns.
Change the order of columns by relatively shifting them to the left with [breakpoint_]gsl(0…12/1) or to the right with [breakpoint_]gsr(0…12/1) classes.
<div class="g g-f">
<div class="gr">
<div class="gc12 SM_gc6 SM_go3">
<!-- Place content here -->
</div>
</div>
</div>Values for each atom are listed in the order they are listed in generated CSS.
(1…10/2)Range of possible values from1to10with step2.[breakpoint_]and[-pseudo]Optional breakpoint and pseudo-element or pseudo-class.{key}and{value}Placeholders for map key and map value.
Example [breakpoint_]fw(100…900/100) expands to fw100, fw200 … SM_fw100, SM_fw200 … LG_fw900.
[breakpoint_]bgc{key}[-pseudo] → background-color: {value}
Specify mapping in $background-colors: (key: value).
bga-f→fixedbga-s→scroll
bgcp-bb→border-boxbgcp-pb→padding-boxbgcp-cb→content-boxbgcp-i→inherit
bgi-n→nonebgi-i→inherit
bgo-bb→border-boxbgo-pb→padding-boxbgo-cb→content-box
bgr-n→no-repeatbgr-x→repeat-xbgr-y→repeat-ybgr-s→spacebgr-r→round
bgz-a→autobgz-ct→containbgz-cv→cover
bgp-tc→top centerbgp-tl→top leftbgp-cr→center rightbgp-cc→center centerbgp-cl→center leftbgp-br→bottom rightbgp-bc→bottom centerbgp-bl→bottom left
bgpx-r→rightbgpx-c→centerbgpx-l→left
bgpy-t→topbgpy-c→centerbgpy-b→bottom
[breakpoint_]fi{key}[-pseudo] → fill: {value}
Specify mapping in $background-colors: (key: value).
[breakpoint_]bdc{key}[-pseudo]→border-color: {value}[breakpoint_]bdxc{key}[-pseudo]=bdlc{key},bdrc{key}[breakpoint_]bdyc{key}[-pseudo]=bdtc{key},bdbc{key}[breakpoint_]bdtc{key}[-pseudo]→border-top-color: {value}[breakpoint_]bdbc{key}[-pseudo]→border-bottom-color: {value}[breakpoint_]bdrc{key}[-pseudo]→border-right-color: {value}[breakpoint_]bdlc{key}[-pseudo]→border-left-color: {value}
Specify mapping in $border-colors: (key: value).
[breakpoint_]bdw{key}→border-width: {value}[breakpoint_]bdxw{key}=bdlw{key},bdrw{key}[breakpoint_]bdyw{key}=bdtw{key},bdbw{key}[breakpoint_]bdtw{key}→border-top-width: {value}[breakpoint_]bdbw{key}→border-bottom-width: {value}[breakpoint_]bdrw{key}→border-right-width: {value}[breakpoint_]bdlw{key}→border-left-width: {value}
Specify mapping in $border-widths: (key: value).
[breakpoint_]bds{key}→border-style: {value}[breakpoint_]bdxs{key}=bdls{key},bdrs{key}[breakpoint_]bdys{key}=bdts{key},bdbs{key}[breakpoint_]bdts{key}→border-top-style: {value}[breakpoint_]bdbs{key}→border-bottom-style: {value}[breakpoint_]bdrs{key}→border-right-style: {value}[breakpoint_]bdls{key}→border-left-style: {value}
Specify mapping in $border-styles: (key: value).
By default, all available border styles are included. Border style atoms are emitted for every breakpoint what can cause significant increase of outputted CSS file. Be sure to remove unused border styles in order to reduce file size.
[breakpoint_]bdr{key}→border-radius: {value}[breakpoint_]bdtr{key}=bdtlr{key},bdtrr{key}[breakpoint_]bdrr{key}=bdtrr{key},bdbrr{key}[breakpoint_]bdbr{key}=bdblr{key},bdbrr{key}[breakpoint_]bdlr{key}=bdtlr{key},bdblr{key}[breakpoint_]bdtrr{key}→border-top-right-radius: {value}[breakpoint_]bdtlr{key}→border-top-left-radius: {value}[breakpoint_]bdbrr{key}→border-bottom-right-radius: {value}[breakpoint_]bdblr{key}→border-bottom-left-radius: {value}
Specify mapping in $border-radiuses: (key: value).
of-n→noneof-f→fillof-ct→containof-cv→coverof-sd→scale-downof-i→inherit
ts-n→nonets-i→inherittsr(45d…360/45d)→transform: rotate(45deg)…rotate(360deg)tsr(-45d…-360/-45d)→transform: rotate(-45deg)…rotate(-360deg)tss(0…200/25)→transform: scale(0)…scale(2)
These shortcuts are available if display atom is included.
[breakpoint_]fx-r=d-fx,fxd-r[breakpoint_]fx-rr=d-fx,fxd-rr[breakpoint_]fx-c=d-fx,fxd-c[breakpoint_]fx-cr=d-fx,fxd-cr
[breakpoint_]fxd-r→row[breakpoint_]fxd-rr→row-reverse[breakpoint_]fxd-c→column[breakpoint_]fxd-cr→column-reverse
[breakpoint_]fxw-n→nowrap[breakpoint_]fxw-w→wrap[breakpoint_]fxw-wr→wrap-reverse
[breakpoint_]fxg(0…10/1) → flex-grow: 0…10
[breakpoint_]fxs(0…10/1) → flex-shrink: 0…10
[breakpoint_]fxb-a→auto[breakpoint_]fxb-mac→max-content[breakpoint_]fxb-mic→min-content[breakpoint_]fxb-fc→fit-content[breakpoint_]fxb-c→content
[breakpoint_]jc-fs→flex-start[breakpoint_]jc-fe→flex-end[breakpoint_]jc-c→center[breakpoint_]jc-sb→space-between[breakpoint_]jc-sa→space-around
[breakpoint_]ai-fs→flex-start[breakpoint_]ai-fe→flex-end[breakpoint_]ai-c→center[breakpoint_]ai-bs→baseline[breakpoint_]ai-s→stretch
[breakpoint_]ac-fs→flex-start[breakpoint_]ac-fe→flex-end[breakpoint_]ac-c→center[breakpoint_]ac-sb→space-between[breakpoint_]ac-sa→space-around[breakpoint_]ac-s→stretch
[breakpoint_]as-a→auto[breakpoint_]as-fs→flex-start[breakpoint_]as-fe→flex-end[breakpoint_]as-c→center[breakpoint_]as-b→baseline[breakpoint_]as-s→stretch
[breakpoint_]ord(0…10/1) → order: 0…10
[breakpoint_]fl-l→left[breakpoint_]fl-r→right[breakpoint_]fl-n→none
cl-l→leftcl-r→rightcl-b→bothcl-n→none
pos-s→staticpos-a→absolutepos-r→relativepos-f→fixed
[breakpoint_]t{key}→top: {value}[breakpoint_]r{key}→right: {value}[breakpoint_]b{key}→bottom: {value}[breakpoint_]l{key}→left: {value}
Specify mapping in $positions: (key: value).
z(0…10/1)→z-index: 0…10z-a→autoz-i→inherit
[breakpoint_]fz-xxs→xx-small[breakpoint_]fz-xs→x-small[breakpoint_]fz-s→small[breakpoint_]fz-m→medium[breakpoint_]fz-l→large[breakpoint_]fz-xl→x-large[breakpoint_]fz-xxl→xx-large[breakpoint_]fz-lr→larger[breakpoint_]fz-sr→smaller[breakpoint_]fz-i→inherit[breakpoint_]fz{key}→font-size: {value}
Specify mapping in $font-sizes: (key: value).
lh-n→normallh-i→inheritlh0→0lh1→1lh{key}→line-height: {value}
Specify mapping in $line-heights: (key: value).
[breakpoint_]fs-s→serif[breakpoint_]fs-ss→sans-serif[breakpoint_]fs-m→monospace[breakpoint_]fs-c→cursive[breakpoint_]fs-f→fantasy[breakpoint_]fs-i→inherit[breakpoint_]fs{key}→font-family: {value}
Specify mapping in $font-families: (key: value).
[breakpoint_]fw(100…900/100)→font-weight: 100…900[breakpoint_]fw-n→normal[breakpoint_]fw-b→bold[breakpoint_]fw-br→bolder[breakpoint_]fw-lr→lighter[breakpoint_]fw-i→inherit
[breakpoint_]fs-n→normal[breakpoint_]fs-i→italic[breakpoint_]fs-o→oblique
fv-cl→common-ligaturesfv-apc→all-petite-capsfv-asc→all-small-capsfv-sc→small-capsfv-c→contextualfv-df→diagonal-fractionsfv-sf→stacked-fractionsfv-hf→historical-formsfv-hl→historical-ligaturesfv-i→inheritfv-n→normalfv-tn→tabular-numsfv-pn→proportional-numsfv-pw→proportional-width
fza-n → none
fst-n→normalfst-uc→ultra-condensedfst-ec→extra-condensedfst-c→condensedfst-sc→semi-condensedfst-se→semi-expandedfst-e→expandedfst-ee→extra-expandedfst-ue→ultra-expanded
wfsm-a→antialiasedwfsm-sa→subpixel-antialiasedwfsm-n→none
mfsm-a→automfsm-g→grayscale
trp-n→nonetrp-a→all
trd(100ms…1000ms/100ms) → transition-duration: 100ms…1000ms
trtf-e→easetrtf-ei→ease-intrtf-eo→ease-outtrtf-eio→ease-in-outtrtf-l→lineartrtf-ss→step-starttrtf-se→step-end
ls-n→normalls-i→inheritls{key}→letter-spacing: {value}
Specify mapping in $letter-spacings: (key: value).
ovw-n→normalovw-b→break-word
[breakpoint_]ta-l→left[breakpoint_]ta-c→center[breakpoint_]ta-r→right[breakpoint_]ta-j→justify
[breakpoint_]tal-l→left[breakpoint_]tal-c→center[breakpoint_]tal-r→right[breakpoint_]tal-j→justify
ti{key} → text-indent: {value}
Specify mapping in $text-indents: (key: value).
[breakpoint_]td-n[-pseudo]→none[breakpoint_]td-u[-pseudo]→underline[breakpoint_]td-o→overline[breakpoint_]td-lt→line-through
tt-c→capitalizett-u→uppercasett-l→lowercasett-n→nonett-fw→full-width
[breakpoint_]ws-n→normal[breakpoint_]ws-p→pre[breakpoint_]ws-nw→nowrap[breakpoint_]ws-pw→pre-wrap[breakpoint_]ws-pl→pre-line
wob-n→normalwob-ka→keep-allwob-ba→break-all
wow-n→normalwow-bw→break-word
lis-n→nonelis-i→inherit
lisp-in→insidelisp-o→outsidelisp-i→inherit
list-n→nonelist-d→disclist-c→circlelist-s→squarelist-dc→decimallist-dclz→decimal-leading-zerolist-lr→lower-romanlist-ur→upper-romanlist-i→inherit
[breakpoint_]c{key}[-pseudo] → color: {value}
Specify mapping in $colors: (key: value).
op(0…100/1) → opacity: 0…1
bxs{key}[-pseudo] → box-shadow: {value}
Specify mapping in $box-shadows: (key: value).
bxz-cb→content-boxbxz-bb→border-boxbxz-i→inherit
[breakpoint_]h{key}→height: {value}[breakpoint_]mah-n→max-height: none[breakpoint_]mah{key}→max-height: {value}[breakpoint_]mih{key}→min-height: {value}
Specify mapping in $heights: (key: value).
[breakpoint_]w{key}→width: {value}[breakpoint_]maw-n→max-width: none[breakpoint_]maw{key}→max-width: {value}[breakpoint_]miw{key}→min-width: {value}
Specify mapping in $widths: (key: value).
[breakpoint_]m{key}→margin: {value}[breakpoint_]mx-a→margin-left: auto,margin-right: auto[breakpoint_]mx{key}=ml{key},mr{key}[breakpoint_]my{key}=mt{key},mb{key}[breakpoint_]mt{key}→margin-top: {value}[breakpoint_]mr{key}→margin-right: {value}[breakpoint_]mb{key}→margin-bottom: {value}[breakpoint_]ml{key}→margin-left: {value}
Specify mapping in $margins: (key: value).
[breakpoint_]p{key}→padding: {value}[breakpoint_]px{key}=pl{key},pr{key}[breakpoint_]py{key}=pt{key},pb{key}[breakpoint_]pt{key}→padding-top: {value}[breakpoint_]pr{key}→padding-right: {value}[breakpoint_]pb100p→padding-bottom: 100%[breakpoint_]pb{key}→padding-bottom: {value}[breakpoint_]pl{key}→padding-left: {value}
Specify mapping in $paddings: (key: value).
ov-v→visibleov-h→hiddenov-s→scrollov-a→auto
ovx-v→visibleovx-h→hiddenovx-s→scrollovx-a→auto
ovy-v→visibleovy-h→hiddenovy-s→scrollovy-a→auto
wovs-t→touchwovs-a→auto
[breakpoint_]v-v→visible[breakpoint_]v-h→hidden[breakpoint_]v-c→collapse
pgbb-a→autopgbb-al→alwayspgbb-av→avoidpgbb-l→leftpgbb-r→right
pgbi-a→autopgbi-av→avoid
pgba-a→autopgba-al→alwayspgba-av→avoidpgba-l→leftpgba-r→right
cur-a→autocur-d→defaultcur-cm→context-menucur-h→helpcur-p→pointercur-ps→progresscur-w→waitcur-cl→cellcur-c→crosshaircur-t→textcur-al→aliascur-cp→copycur-m→movecur-nd→no-dropcur-na→not-allowedcur-as→all-scrollcur-cr→col-resizecur-rr→row-resizecur-nr→n-resizecur-er→e-resizecur-sr→s-resizecur-wr→w-resizecur-ner→ne-resizecur-nwr→nw-resizecur-ser→se-resizecur-swr→sw-resizecur-ewr→ew-resizecur-nsr→ns-resizecur-neswr→nesw-resizecur-nwser→nwse-resizecur-zi→zoom-incur-zo→zoom-outcur-g→grabcur-gr→grabbingcur-n→none
rz-n→nonerz-b→bothrz-h→horizontalrz-v→vertical
tov-e→ellipsistov-c→clip
us-n→noneus-t→textus-a→all
bdce-c→collapsebdce-s→separatebdce-i→inherit
cps-t→topcps-b→bottom
ec-s→showec-h→hide
tbl-a→autotbl-f→fixed
va-sp→superva-t→topva-tt→text-topva-m→middleva-bs→baselineva-b→bottomva-tb→text-bottomva-sb→sub
d-n→noned-b→blockd-fx→flexd-li→list-itemd-ri→run-ind-i→inlined-itb→inline-tabled-ifx→inline-flexd-ib→inline-blockd-tb→tabled-tcp→table-captiond-tc→table-columnd-tcg→table-column-groupd-thg→table-header-groupd-tfg→table-footer-groupd-tr→table-rowd-trg→table-row-groupd-tcl→table-celld-rb→rubyd-rbb→ruby-based-rbbc→ruby-base-containerd-rbt→ruby-textd-rbtc→ruby-text-container
The code is available under MIT licence.