Skip to content
This repository has been archived by the owner on Oct 21, 2024. It is now read-only.

grabr/quantum-css

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Quantum CSS

npm version travis ci status

“Everything should be made as simple as possible, but no simpler.” – Albert Einstein 1

Preface

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.

Contents

  1. Naming Conventions
  1. Breakpoints

  2. Pseudo-classes and Pseudo-elements

  3. Grid System

  1. Atom Index
  1. License

Naming Conventions

In Quantum CSS every class name consists of four parts in given order:

  1. Optional breakpoint name: SM, MD etc.
  2. Property abbreviation: bdtc, ws etc.
  3. Value abbreviation: w, 100p, 360d etc.
  4. Optional pseudo-class or pseudo-element modifier: hf, h etc.

You can configure separators between each parts of class name with following variables:

  • $breakpoint-sep define separator between breakpoint name and property abbreviation.

  • $literal-sep and $ordinal-sep define separators that are inserted between property name and literal value abbreviation or ordinal one respectively.

  • $pseudo-sep defines separator between pseudo modifier from value abbreviation.

Value Aliases

Aliases for commonly used values:

  • p%
  • eem
  • xex
  • rrem
  • ddeg
  • tturn

These aliases are used instead of full units:

  • w100pwidth: 100%
  • SM_mah42@media (min-width: 576px) { max-height: 42px }

Color Values

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
  1. White w | #fff
  2. Grey 15% g1 | #eeeeec
  3. Grey 30% g2 | #d3d7cf
  4. Grey 45% g3 | #babdb6
  5. Grey 60% g4 | #888a85
  6. Grey 75% g5 | #555753
  7. Grey 90% g6 | #2e3436
  8. Black b | #000
Color Light l Medium Dark d
  1. Yellow y | #fce94f | #edd400 | #c4a000
  2. Orange o | #fcaf3e | #f57900 | #ce5c00
  3. Chocolate c | #e9b96e | #c17d11 | #8f5902
  4. Green g | #8ae234 | #73d216 | #4e9a06
  5. Navy n | #729fcf | #3465a4 | #204a87
  6. Purple p | #ad7f8a | #75507b | #5c3566
  7. Red r | #ef2929 | #cc0000 | #a40000

CSS-literal colors:

Generated atom examples:

  • SM_bgc-dgbackground-color: #4e9a06 Dark green
  • bdrc-wborder-right-color: white
  • LG_c-bcolor: black

Unit-less Properties

Some CSS properties are defined as unit-less, e.g. no unit suffix will be outputted:

  • lh1line-height: 1
  • fw400font-weight: 400
  • op37opacity: 0.37

Breakpoints

One of the most powerful features of Quantum is breakpoint-based media queries.

Pseudo-classes and Pseudo-elements

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

Grid System

Containers g

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 gr

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>

Columns gc

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>

Column Ordering

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>

Atom Index

Values for each atom are listed in the order they are listed in generated CSS.

Name Pattern

  • (1…10/2) Range of possible values from 1 to 10 with step 2.
  • [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, fw200SM_fw100, SM_fw200LG_fw900.

Background

[breakpoint_]bgc{key}[-pseudo]background-color: {value}

Specify mapping in $background-colors: (key: value).

  1. bga-ffixed
  2. bga-sscroll
  1. bgcp-bbborder-box
  2. bgcp-pbpadding-box
  3. bgcp-cbcontent-box
  4. bgcp-iinherit
  1. bgi-nnone
  2. bgi-iinherit
  1. bgo-bbborder-box
  2. bgo-pbpadding-box
  3. bgo-cbcontent-box
  1. bgr-nno-repeat
  2. bgr-xrepeat-x
  3. bgr-yrepeat-y
  4. bgr-sspace
  5. bgr-rround
  1. bgz-aauto
  2. bgz-ctcontain
  3. bgz-cvcover
  1. bgp-tctop center
  2. bgp-tltop left
  3. bgp-crcenter right
  4. bgp-cccenter center
  5. bgp-clcenter left
  6. bgp-brbottom right
  7. bgp-bcbottom center
  8. bgp-blbottom left
  1. bgpx-rright
  2. bgpx-ccenter
  3. bgpx-lleft
  1. bgpy-ttop
  2. bgpy-ccenter
  3. bgpy-bbottom

[breakpoint_]fi{key}[-pseudo]fill: {value}

Specify mapping in $background-colors: (key: value).

Border

  1. [breakpoint_]bdc{key}[-pseudo]border-color: {value}
  2. [breakpoint_]bdxc{key}[-pseudo] = bdlc{key}, bdrc{key}
  3. [breakpoint_]bdyc{key}[-pseudo] = bdtc{key}, bdbc{key}
  4. [breakpoint_]bdtc{key}[-pseudo]border-top-color: {value}
  5. [breakpoint_]bdbc{key}[-pseudo]border-bottom-color: {value}
  6. [breakpoint_]bdrc{key}[-pseudo]border-right-color: {value}
  7. [breakpoint_]bdlc{key}[-pseudo]border-left-color: {value}

Specify mapping in $border-colors: (key: value).

  1. [breakpoint_]bdw{key}border-width: {value}
  2. [breakpoint_]bdxw{key} = bdlw{key}, bdrw{key}
  3. [breakpoint_]bdyw{key} = bdtw{key}, bdbw{key}
  4. [breakpoint_]bdtw{key}border-top-width: {value}
  5. [breakpoint_]bdbw{key}border-bottom-width: {value}
  6. [breakpoint_]bdrw{key}border-right-width: {value}
  7. [breakpoint_]bdlw{key}border-left-width: {value}

Specify mapping in $border-widths: (key: value).

  1. [breakpoint_]bds{key}border-style: {value}
  2. [breakpoint_]bdxs{key} = bdls{key}, bdrs{key}
  3. [breakpoint_]bdys{key} = bdts{key}, bdbs{key}
  4. [breakpoint_]bdts{key}border-top-style: {value}
  5. [breakpoint_]bdbs{key}border-bottom-style: {value}
  6. [breakpoint_]bdrs{key}border-right-style: {value}
  7. [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.

  1. [breakpoint_]bdr{key}border-radius: {value}
  2. [breakpoint_]bdtr{key} = bdtlr{key}, bdtrr{key}
  3. [breakpoint_]bdrr{key} = bdtrr{key}, bdbrr{key}
  4. [breakpoint_]bdbr{key} = bdblr{key}, bdbrr{key}
  5. [breakpoint_]bdlr{key} = bdtlr{key}, bdblr{key}
  6. [breakpoint_]bdtrr{key}border-top-right-radius: {value}
  7. [breakpoint_]bdtlr{key}border-top-left-radius: {value}
  8. [breakpoint_]bdbrr{key}border-bottom-right-radius: {value}
  9. [breakpoint_]bdblr{key}border-bottom-left-radius: {value}

Specify mapping in $border-radiuses: (key: value).

Images

  1. of-nnone
  2. of-ffill
  3. of-ctcontain
  4. of-cvcover
  5. of-sdscale-down
  6. of-iinherit

Transforms

  1. ts-nnone
  2. ts-iinherit
  3. tsr(45d…360/45d)transform: rotate(45deg)rotate(360deg)
  4. tsr(-45d…-360/-45d)transform: rotate(-45deg)rotate(-360deg)
  5. tss(0…200/25)transform: scale(0)scale(2)

Flexible Box Layout

These shortcuts are available if display atom is included.

  1. [breakpoint_]fx-r = d-fx, fxd-r
  2. [breakpoint_]fx-rr = d-fx, fxd-rr
  3. [breakpoint_]fx-c = d-fx, fxd-c
  4. [breakpoint_]fx-cr = d-fx, fxd-cr
  1. [breakpoint_]fxd-rrow
  2. [breakpoint_]fxd-rrrow-reverse
  3. [breakpoint_]fxd-ccolumn
  4. [breakpoint_]fxd-crcolumn-reverse
  1. [breakpoint_]fxw-nnowrap
  2. [breakpoint_]fxw-wwrap
  3. [breakpoint_]fxw-wrwrap-reverse

[breakpoint_]fxg(0…10/1)flex-grow: 010

[breakpoint_]fxs(0…10/1)flex-shrink: 010

  1. [breakpoint_]fxb-aauto
  2. [breakpoint_]fxb-macmax-content
  3. [breakpoint_]fxb-micmin-content
  4. [breakpoint_]fxb-fcfit-content
  5. [breakpoint_]fxb-ccontent
  1. [breakpoint_]jc-fsflex-start
  2. [breakpoint_]jc-feflex-end
  3. [breakpoint_]jc-ccenter
  4. [breakpoint_]jc-sbspace-between
  5. [breakpoint_]jc-saspace-around
  1. [breakpoint_]ai-fsflex-start
  2. [breakpoint_]ai-feflex-end
  3. [breakpoint_]ai-ccenter
  4. [breakpoint_]ai-bsbaseline
  5. [breakpoint_]ai-sstretch
  1. [breakpoint_]ac-fsflex-start
  2. [breakpoint_]ac-feflex-end
  3. [breakpoint_]ac-ccenter
  4. [breakpoint_]ac-sbspace-between
  5. [breakpoint_]ac-saspace-around
  6. [breakpoint_]ac-sstretch
  1. [breakpoint_]as-aauto
  2. [breakpoint_]as-fsflex-start
  3. [breakpoint_]as-feflex-end
  4. [breakpoint_]as-ccenter
  5. [breakpoint_]as-bbaseline
  6. [breakpoint_]as-sstretch

[breakpoint_]ord(0…10/1)order: 010

Positioning

  1. [breakpoint_]fl-lleft
  2. [breakpoint_]fl-rright
  3. [breakpoint_]fl-nnone
  1. cl-lleft
  2. cl-rright
  3. cl-bboth
  4. cl-nnone
  1. pos-sstatic
  2. pos-aabsolute
  3. pos-rrelative
  4. pos-ffixed
  1. [breakpoint_]t{key}top: {value}
  2. [breakpoint_]r{key}right: {value}
  3. [breakpoint_]b{key}bottom: {value}
  4. [breakpoint_]l{key}left: {value}

Specify mapping in $positions: (key: value).

  1. z(0…10/1)z-index: 010
  2. z-aauto
  3. z-iinherit

Fonts

  1. [breakpoint_]fz-xxsxx-small
  2. [breakpoint_]fz-xsx-small
  3. [breakpoint_]fz-ssmall
  4. [breakpoint_]fz-mmedium
  5. [breakpoint_]fz-llarge
  6. [breakpoint_]fz-xlx-large
  7. [breakpoint_]fz-xxlxx-large
  8. [breakpoint_]fz-lrlarger
  9. [breakpoint_]fz-srsmaller
  10. [breakpoint_]fz-iinherit
  11. [breakpoint_]fz{key}font-size: {value}

Specify mapping in $font-sizes: (key: value).

  1. lh-nnormal
  2. lh-iinherit
  3. lh00
  4. lh11
  5. lh{key}line-height: {value}

Specify mapping in $line-heights: (key: value).

  1. [breakpoint_]fs-sserif
  2. [breakpoint_]fs-sssans-serif
  3. [breakpoint_]fs-mmonospace
  4. [breakpoint_]fs-ccursive
  5. [breakpoint_]fs-ffantasy
  6. [breakpoint_]fs-iinherit
  7. [breakpoint_]fs{key}font-family: {value}

Specify mapping in $font-families: (key: value).

  1. [breakpoint_]fw(100…900/100)font-weight: 100900
  2. [breakpoint_]fw-nnormal
  3. [breakpoint_]fw-bbold
  4. [breakpoint_]fw-brbolder
  5. [breakpoint_]fw-lrlighter
  6. [breakpoint_]fw-iinherit
  1. [breakpoint_]fs-nnormal
  2. [breakpoint_]fs-iitalic
  3. [breakpoint_]fs-ooblique
  1. fv-clcommon-ligatures
  2. fv-apcall-petite-caps
  3. fv-ascall-small-caps
  4. fv-scsmall-caps
  5. fv-ccontextual
  6. fv-dfdiagonal-fractions
  7. fv-sfstacked-fractions
  8. fv-hfhistorical-forms
  9. fv-hlhistorical-ligatures
  10. fv-iinherit
  11. fv-nnormal
  12. fv-tntabular-nums
  13. fv-pnproportional-nums
  14. fv-pwproportional-width

fza-nnone

  1. fst-nnormal
  2. fst-ucultra-condensed
  3. fst-ecextra-condensed
  4. fst-ccondensed
  5. fst-scsemi-condensed
  6. fst-sesemi-expanded
  7. fst-eexpanded
  8. fst-eeextra-expanded
  9. fst-ueultra-expanded
  1. wfsm-aantialiased
  2. wfsm-sasubpixel-antialiased
  3. wfsm-nnone
  1. mfsm-aauto
  2. mfsm-ggrayscale

Transitions

  1. trp-nnone
  2. trp-aall

trd(100ms…1000ms/100ms)transition-duration: 100ms1000ms

  1. trtf-eease
  2. trtf-eiease-in
  3. trtf-eoease-out
  4. trtf-eioease-in-out
  5. trtf-llinear
  6. trtf-ssstep-start
  7. trtf-sestep-end

Text

  1. ls-nnormal
  2. ls-iinherit
  3. ls{key}letter-spacing: {value}

Specify mapping in $letter-spacings: (key: value).

  1. ovw-nnormal
  2. ovw-bbreak-word
  1. [breakpoint_]ta-lleft
  2. [breakpoint_]ta-ccenter
  3. [breakpoint_]ta-rright
  4. [breakpoint_]ta-jjustify
  1. [breakpoint_]tal-lleft
  2. [breakpoint_]tal-ccenter
  3. [breakpoint_]tal-rright
  4. [breakpoint_]tal-jjustify

ti{key}text-indent: {value}

Specify mapping in $text-indents: (key: value).

  1. [breakpoint_]td-n[-pseudo]none
  2. [breakpoint_]td-u[-pseudo]underline
  3. [breakpoint_]td-ooverline
  4. [breakpoint_]td-ltline-through
  1. tt-ccapitalize
  2. tt-uuppercase
  3. tt-llowercase
  4. tt-nnone
  5. tt-fwfull-width
  1. [breakpoint_]ws-n normal
  2. [breakpoint_]ws-p pre
  3. [breakpoint_]ws-nwnowrap
  4. [breakpoint_]ws-pwpre-wrap
  5. [breakpoint_]ws-plpre-line
  1. wob-nnormal
  2. wob-kakeep-all
  3. wob-babreak-all
  1. wow-nnormal
  2. wow-bwbreak-word

Lists and Counters

  1. lis-nnone
  2. lis-iinherit
  1. lisp-ininside
  2. lisp-ooutside
  3. lisp-iinherit
  1. list-nnone
  2. list-ddisc
  3. list-ccircle
  4. list-ssquare
  5. list-dcdecimal
  6. list-dclzdecimal-leading-zero
  7. list-lrlower-roman
  8. list-urupper-roman
  9. list-iinherit

Colors

[breakpoint_]c{key}[-pseudo]color: {value}

Specify mapping in $colors: (key: value).

op(0…100/1)opacity: 01

Box Model

bxs{key}[-pseudo]box-shadow: {value}

Specify mapping in $box-shadows: (key: value).

  1. bxz-cbcontent-box
  2. bxz-bbborder-box
  3. bxz-iinherit
  1. [breakpoint_]h{key}height: {value}
  2. [breakpoint_]mah-nmax-height: none
  3. [breakpoint_]mah{key}max-height: {value}
  4. [breakpoint_]mih{key}min-height: {value}

Specify mapping in $heights: (key: value).

  1. [breakpoint_]w{key}width: {value}
  2. [breakpoint_]maw-nmax-width: none
  3. [breakpoint_]maw{key}max-width: {value}
  4. [breakpoint_]miw{key}min-width: {value}

Specify mapping in $widths: (key: value).

  1. [breakpoint_]m{key}margin: {value}
  2. [breakpoint_]mx-amargin-left: auto, margin-right: auto
  3. [breakpoint_]mx{key} = ml{key}, mr{key}
  4. [breakpoint_]my{key} = mt{key}, mb{key}
  5. [breakpoint_]mt{key}margin-top: {value}
  6. [breakpoint_]mr{key}margin-right: {value}
  7. [breakpoint_]mb{key}margin-bottom: {value}
  8. [breakpoint_]ml{key}margin-left: {value}

Specify mapping in $margins: (key: value).

  1. [breakpoint_]p{key}padding: {value}
  2. [breakpoint_]px{key} = pl{key}, pr{key}
  3. [breakpoint_]py{key} = pt{key}, pb{key}
  4. [breakpoint_]pt{key}padding-top: {value}
  5. [breakpoint_]pr{key}padding-right: {value}
  6. [breakpoint_]pb100ppadding-bottom: 100%
  7. [breakpoint_]pb{key}padding-bottom: {value}
  8. [breakpoint_]pl{key}padding-left: {value}

Specify mapping in $paddings: (key: value).

  1. ov-vvisible
  2. ov-hhidden
  3. ov-sscroll
  4. ov-aauto
  1. ovx-vvisible
  2. ovx-hhidden
  3. ovx-sscroll
  4. ovx-aauto
  1. ovy-vvisible
  2. ovy-hhidden
  3. ovy-sscroll
  4. ovy-aauto
  1. wovs-ttouch
  2. wovs-aauto
  1. [breakpoint_]v-vvisible
  2. [breakpoint_]v-hhidden
  3. [breakpoint_]v-ccollapse

Page

  1. pgbb-aauto
  2. pgbb-alalways
  3. pgbb-avavoid
  4. pgbb-lleft
  5. pgbb-rright
  1. pgbi-aauto
  2. pgbi-avavoid
  1. pgba-aauto
  2. pgba-alalways
  3. pgba-avavoid
  4. pgba-lleft
  5. pgba-rright

User Interface

  1. cur-aauto
  2. cur-ddefault
  3. cur-cmcontext-menu
  4. cur-hhelp
  5. cur-ppointer
  6. cur-psprogress
  7. cur-wwait
  8. cur-clcell
  9. cur-ccrosshair
  10. cur-ttext
  11. cur-alalias
  12. cur-cpcopy
  13. cur-mmove
  14. cur-ndno-drop
  15. cur-nanot-allowed
  16. cur-asall-scroll
  17. cur-crcol-resize
  18. cur-rrrow-resize
  19. cur-nrn-resize
  20. cur-ere-resize
  21. cur-srs-resize
  22. cur-wrw-resize
  23. cur-nerne-resize
  24. cur-nwrnw-resize
  25. cur-serse-resize
  26. cur-swrsw-resize
  27. cur-ewrew-resize
  28. cur-nsrns-resize
  29. cur-neswrnesw-resize
  30. cur-nwsernwse-resize
  31. cur-zizoom-in
  32. cur-zozoom-out
  33. cur-ggrab
  34. cur-grgrabbing
  35. cur-nnone
  1. rz-nnone
  2. rz-bboth
  3. rz-hhorizontal
  4. rz-vvertical
  1. tov-eellipsis
  2. tov-cclip
  1. us-nnone
  2. us-ttext
  3. us-aall

Table

  1. bdce-ccollapse
  2. bdce-sseparate
  3. bdce-iinherit
  1. cps-ttop
  2. cps-bbottom
  1. ec-sshow
  2. ec-hhide
  1. tbl-aauto
  2. tbl-ffixed
  1. va-spsuper
  2. va-ttop
  3. va-tttext-top
  4. va-mmiddle
  5. va-bsbaseline
  6. va-bbottom
  7. va-tbtext-bottom
  8. va-sbsub

Miscellaneous

  1. d-nnone
  2. d-bblock
  3. d-fxflex
  4. d-lilist-item
  5. d-rirun-in
  6. d-iinline
  7. d-itbinline-table
  8. d-ifxinline-flex
  9. d-ibinline-block
  10. d-tbtable
  11. d-tcptable-caption
  12. d-tctable-column
  13. d-tcgtable-column-group
  14. d-thgtable-header-group
  15. d-tfgtable-footer-group
  16. d-trtable-row
  17. d-trgtable-row-group
  18. d-tcltable-cell
  19. d-rbruby
  20. d-rbbruby-base
  21. d-rbbcruby-base-container
  22. d-rbtruby-text
  23. d-rbtcruby-text-container

License

The code is available under MIT licence.

Releases

No releases published

Packages

No packages published