NexusCS

Tachyons

CSS
Tachyons is a functional CSS toolkit with composable utility classes for rapid UI development. Mobile-first, highly performant, and human-readable.
css
functional-css
utility-first
atomic-css

Getting Started

Introduction

Tachyons is a functional CSS framework that provides small, single-purpose classes for building interfaces directly in HTML. It follows atomic CSS principles and uses a mobile-first responsive approach.

Installation

<!-- CDN -->
<link
  rel="stylesheet"
  href="https://unpkg.com/[email protected]/css/tachyons.min.css"
/>
# npm
npm install [email protected]
/* Import in CSS */
@import "tachyons";

Quick Example

<div class="pa4 bg-blue white">
  <h1 class="f2 fw7 mb3">Hello Tachyons</h1>
  <p class="f5 lh-copy measure">
    Rapidly build user interfaces with composable classes.
  </p>
</div>

Basic Card

<article class="br3 ba b--black-10 mv4 w-100 w-50-m w-25-l mw6 shadow-5 center">
  <img src="img.jpg" class="w-100 db br3 br--top" alt="Photo" />
  <div class="pa2 ph3-ns pb3-ns">
    <div class="dt w-100 mt1">
      <div class="dtc">
        <h1 class="f5 f4-ns mv0">Title</h1>
      </div>
      <div class="dtc tr">
        <h2 class="f5 mv0 gray">$24.99</h2>
      </div>
    </div>
    <p class="f6 lh-copy measure mt2 mid-gray">Description text goes here.</p>
  </div>
</article>

Spacing Scale

Spacing Values

Step Class Suffix Value Pixels
0 *0 0 0px
1 *1 .25rem 4px
2 *2 .5rem 8px
3 *3 1rem 16px
4 *4 2rem 32px
5 *5 4rem 64px
6 *6 8rem 128px
7 *7 16rem 256px

Powers of two progression for consistent rhythm.

Padding Classes

Class CSS Description
.pa{0-7} padding: * All sides
.ph{0-7} padding-left/right: * Horizontal
.pv{0-7} padding-top/bottom: * Vertical
.pt{0-7} padding-top: * Top only
.pr{0-7} padding-right: * Right only
.pb{0-7} padding-bottom: * Bottom only
.pl{0-7} padding-left: * Left only

Margin Classes

Class CSS Description
.ma{0-7} margin: * All sides
.mh{0-7} margin-left/right: * Horizontal
.mv{0-7} margin-top/bottom: * Vertical
.mt{0-7} margin-top: * Top only
.mr{0-7} margin-right: * Right only
.mb{0-7} margin-bottom: * Bottom only
.ml{0-7} margin-left: * Left only
.center margin: 0 auto Horizontal center

Negative Margins

Class CSS
.na{1-7} margin: -[value]
.nl{1-7} margin-left: -[value]
.nr{1-7} margin-right: -[value]
.nt{1-7} margin-top: -[value]
.nb{1-7} margin-bottom: -[value]

Typography

Font Sizes

Class Size ~Pixels Use Case
.f-headline 6rem 96px Hero text
.f-subheadline 5rem 80px Large headers
.f1 3rem 48px Page title
.f2 2.25rem 36px Section header
.f3 1.5rem 24px Subsection
.f4 1.25rem 20px Large body
.f5 1rem 16px Body text
.f6 .875rem 14px Small text
.f7 .75rem 12px Fine print

Also available: .f-6 (same as .f-headline)

Font Weights

Class Weight Name
.normal 400 Normal
.b 700 Bold
.fw1 100 Thin
.fw2 200 Extra Light
.fw3 300 Light
.fw4 400 Normal
.fw5 500 Medium
.fw6 600 Semi-Bold
.fw7 700 Bold
.fw8 800 Extra Bold
.fw9 900 Heavy

Font Families

Class Font Stack
.sans-serif System sans-serif
.serif Georgia, Times
.code Consolas, Monaco, monospace
.courier Courier Next
.helvetica Helvetica Neue
.avenir Avenir Next
.athelas Athelas, Georgia
.georgia Georgia
.times Times
.bodoni Bodoni MT
.calisto Calisto MT
.garamond Garamond
.baskerville Baskerville

Text Alignment

Class CSS
.tl text-align: left
.tc text-align: center
.tr text-align: right
.tj text-align: justify

Text Transform

Class CSS
.ttu text-transform: uppercase
.ttl text-transform: lowercase
.ttc text-transform: capitalize
.ttn text-transform: none

Text Decoration

Class CSS
.underline text-decoration: underline
.strike text-decoration: line-through
.no-underline text-decoration: none

Line Height

Class Value Use Case
.lh-solid 1 Headings
.lh-title 1.25 Titles
.lh-copy 1.5 Body text

Letter Spacing

Class Value
.tracked .1em
.tracked-tight -.05em
.tracked-mega .25em

Measure (Max-Width)

Class Max-Width Characters
.measure 30em ~66 chars
.measure-wide 34em ~80 chars
.measure-narrow 20em ~45 chars

Optimal line length for readability.

Text Style

Class CSS
.i font-style: italic
.fs-normal font-style: normal
.small-caps font-variant: small-caps

Layout

Display

Class CSS
.dn display: none
.di display: inline
.db display: block
.dib display: inline-block
.dit display: inline-table
.dt display: table
.dtc display: table-cell
.dt-row display: table-row
.dt-row-group display: table-row-group
.dt-column display: table-column
.dt-column-group display: table-column-group

Widths (Fixed)

Class Value
.w1 1rem (16px)
.w2 2rem (32px)
.w3 4rem (64px)
.w4 8rem (128px)
.w5 16rem (256px)

Widths (Percentage)

Class Value
.w-10 10%
.w-20 20%
.w-25 25%
.w-30 30%
.w-33 33.33%
.w-34 34%
.w-40 40%
.w-50 50%
.w-60 60%
.w-70 70%
.w-75 75%
.w-80 80%
.w-90 90%
.w-100 100%
.w-third 33.333%
.w-two-thirds 66.667%
.w-auto auto

Max-Width

Class Value
.mw1 1rem
.mw2 2rem
.mw3 4rem
.mw4 8rem
.mw5 16rem
.mw6 32rem
.mw7 48rem
.mw8 64rem
.mw9 96rem
.mw-100 100%
.mw-none none

Heights (Fixed)

Class Value
.h1 1rem
.h2 2rem
.h3 4rem
.h4 8rem
.h5 16rem

Heights (Percentage)

Class Value
.h-25 25%
.h-50 50%
.h-75 75%
.h-100 100%
.h-auto auto
.h-inherit inherit

Viewport Heights

Class Value
.vh-25 25vh
.vh-50 50vh
.vh-75 75vh
.vh-100 100vh

Min/Max Heights

Class Value
.min-h-100 100%
.min-vh-100 100vh
.mh0 0
.mh1.mh5 1–16rem
.mh-100 100%
.mh-none none

Flexbox

Flex Container

Class CSS
.flex display: flex
.inline-flex display: inline-flex

Flex Direction

Class CSS
.flex-row flex-direction: row
.flex-row-reverse flex-direction: row-reverse
.flex-column flex-direction: column
.flex-column-reverse flex-direction: column-reverse

Flex Wrap

Class CSS
.flex-wrap flex-wrap: wrap
.flex-nowrap flex-wrap: nowrap
.flex-wrap-reverse flex-wrap: wrap-reverse

Flex Item

Class CSS
.flex-auto flex: 1 1 auto
.flex-none flex: none

Align Items

Class CSS
.items-start align-items: flex-start
.items-end align-items: flex-end
.items-center align-items: center
.items-baseline align-items: baseline
.items-stretch align-items: stretch

Align Self

Class CSS
.self-start align-self: flex-start
.self-end align-self: flex-end
.self-center align-self: center
.self-baseline align-self: baseline
.self-stretch align-self: stretch

Justify Content

Class CSS
.justify-start justify-content: flex-start
.justify-end justify-content: flex-end
.justify-center justify-content: center
.justify-between justify-content: space-between
.justify-around justify-content: space-around

Align Content

Class CSS
.content-start align-content: flex-start
.content-end align-content: flex-end
.content-center align-content: center
.content-between align-content: space-between
.content-around align-content: space-around
.content-stretch align-content: stretch

Order

Class Value
.order-0 0
.order-1 1
.order-2 2
.order-3 3
.order-4 4
.order-5 5
.order-6 6
.order-7 7
.order-8 8
.order-last 99999

Colors

Color Palette

Dark Colors: black, near-black, dark-gray, mid-gray, gray

Light Colors: silver, light-silver, moon-gray, light-gray, near-white, white

Reds: dark-red, red, light-red, washed-red

Oranges/Yellows: orange, gold, yellow, light-yellow, washed-yellow

Greens: dark-green, green, light-green, washed-green

Blues: navy, dark-blue, blue, light-blue, lightest-blue, washed-blue

Purples/Pinks: purple, light-purple, dark-pink, hot-pink, pink, light-pink

Color Usage Patterns

Pattern Example Effect
.{color} .blue Text color
.bg-{color} .bg-blue Background
.b--{color} .b--blue Border color
.hover-{color} .hover-blue Hover text
.hover-bg-{color} .hover-bg-blue Hover background
.focus-{color} .focus-blue Focus text

Color Example

<!-- Text colors -->
<p class="blue">Blue text</p>
<p class="dark-red">Dark red text</p>

<!-- Backgrounds -->
<div class="bg-light-blue pa3">Light blue background</div>

<!-- Borders -->
<div class="ba b--green">Green border</div>

<!-- Hover states -->
<a href="#" class="blue hover-dark-blue">Hover me</a>

Transparent Colors

Class Opacity
.black-90 rgba(0,0,0,.9)
.black-80 rgba(0,0,0,.8)
.black-70 rgba(0,0,0,.7)
.black-60 rgba(0,0,0,.6)
.black-50 rgba(0,0,0,.5)
.black-40 rgba(0,0,0,.4)
.black-30 rgba(0,0,0,.3)
.black-20 rgba(0,0,0,.2)
.black-10 rgba(0,0,0,.1)
.black-05 rgba(0,0,0,.05)
.black-025 rgba(0,0,0,.025)
.black-0125 rgba(0,0,0,.0125)

Same pattern for .white-* with rgba(255,255,255,*)

Borders

Border Sides

Class Effect
.ba All sides
.bt Top
.br Right
.bb Bottom
.bl Left
.bn None (remove)

Border Widths

Class Value
.bw0 0
.bw1 .125rem
.bw2 .25rem
.bw3 .5rem
.bw4 1rem
.bw5 2rem

Border Styles

Class CSS
.b--solid border-style: solid
.b--dashed border-style: dashed
.b--dotted border-style: dotted
.b--none border-style: none

Border Radius

Class Value
.br0 0
.br1 .125rem
.br2 .25rem
.br3 .5rem
.br4 1rem
.br-100 100%
.br-pill 9999px

Border Radius Sides

Class Effect
.br--top Top corners
.br--right Right corners
.br--bottom Bottom corners
.br--left Left corners

Border Example

<!-- Card with rounded corners -->
<div class="ba br3 b--black-10 pa3">Rounded card</div>

<!-- Pill button -->
<button class="br-pill ba b--blue bg-blue white ph4 pv2">Click me</button>

<!-- Circle avatar -->
<img src="avatar.jpg" class="br-100 w3 h3" alt="Avatar" />

Position

Position Types

Class CSS
.static position: static
.relative position: relative
.absolute position: absolute
.fixed position: fixed
.sticky position: sticky

Top/Right/Bottom/Left

Class Value
.top-0 top: 0
.top-1 top: 1rem
.top-2 top: 2rem
.right-0 right: 0
.right-1 right: 1rem
.right-2 right: 2rem
.bottom-0 bottom: 0
.bottom-1 bottom: 1rem
.bottom-2 bottom: 2rem
.left-0 left: 0
.left-1 left: 1rem
.left-2 left: 2rem

Position Helpers

Class CSS
.absolute--fill top/right/bottom/left: 0

Fills parent with absolute positioning.

Z-Index

Class Value
.z-0 0
.z-1 1
.z-2 2
.z-3 3
.z-4 4
.z-5 5
.z-999 999
.z-9999 9999
.z-max 2147483647
.z-inherit inherit
.z-initial initial
.z-unset unset

Responsive Design

Breakpoints

Suffix Name Min-Width Pixels
(none) Base 0 Mobile-first
-ns Not Small 30em 480px
-m Medium 30em–60em 480–960px
-l Large 60em+ 960px+

Note: -m is for medium screens only (not including large).

Responsive Examples

<!-- Full width on mobile, 50% on tablet+ -->
<div class="w-100 w-50-ns">...</div>

<!-- Hidden on mobile, block on tablet+ -->
<div class="dn db-ns">...</div>

<!-- Different padding at different sizes -->
<div class="pa2 pa3-ns pa4-l">...</div>

<!-- Responsive font sizes -->
<h1 class="f3 f2-m f1-l">Responsive heading</h1>

<!-- Stack on mobile, flex row on tablet+ -->
<div class="flex-column flex-row-ns">
  <div class="w-100 w-50-ns">Column 1</div>
  <div class="w-100 w-50-ns">Column 2</div>
</div>

Media Query Reference

/* Not Small (ns) */
@media screen and (min-width: 30em) {
}

/* Medium (m) */
@media screen and (min-width: 30em) and (max-width: 60em) {
}

/* Large (l) */
@media screen and (min-width: 60em) {
}

Mobile-First Approach

Classes apply from their breakpoint up:

  • .dn-ns = hidden at 480px and above
  • .db-l = block at 960px and above
  • No suffix = applies to all sizes

Floats & Clears

Floats

Class CSS
.fl float: left
.fr float: right
.fn float: none

Clearfix

Class Effect
.cf Clearfix (::after)
.cl clear: left
.cr clear: right
.cb clear: both
.cn clear: none

Float Example

<div class="cf">
  <img src="image.jpg" class="fl w-25 mr3" alt="Float left" />
  <p>Text wraps around floated image...</p>
</div>

Effects & Utilities

Opacity

Class Value
.o-100 1
.o-90 .9
.o-80 .8
.o-70 .7
.o-60 .6
.o-50 .5
.o-40 .4
.o-30 .3
.o-20 .2
.o-10 .1
.o-05 .05
.o-025 .025
.o-0 0

Hover Effects

Class Effect
.dim Opacity .5 transition
.glow Box-shadow on hover
.grow Scale 1.05
.grow-large Scale 1.2
.pointer cursor: pointer
.shadow-hover Box-shadow on hover

Transitions

Class Duration
.o-05-ns Opacity with transition

All hover effects include smooth transitions.

Overflow

Class CSS
.overflow-visible overflow: visible
.overflow-hidden overflow: hidden
.overflow-scroll overflow: scroll
.overflow-auto overflow: auto
.overflow-x-visible overflow-x: visible
.overflow-x-hidden overflow-x: hidden
.overflow-x-scroll overflow-x: scroll
.overflow-x-auto overflow-x: auto
.overflow-y-visible overflow-y: visible
.overflow-y-hidden overflow-y: hidden
.overflow-y-scroll overflow-y: scroll
.overflow-y-auto overflow-y: auto

Cursor

Class CSS
.pointer cursor: pointer

Visibility

Class CSS
.clip Accessible hiding (screen readers only)

Vertical Align

Vertical Alignment

Class CSS
.v-base vertical-align: baseline
.v-mid vertical-align: middle
.v-top vertical-align: top
.v-btm vertical-align: bottom

Table Vertical Align

Use with .dtc (display: table-cell):

<div class="dt w-100">
  <div class="dtc v-mid">Vertically centered content</div>
</div>

Box Shadow

Shadow Classes

Class Effect
.shadow-1 Small shadow
.shadow-2 Medium shadow
.shadow-3 Large shadow
.shadow-4 Extra large shadow
.shadow-5 Huge shadow

Shadow Example

<div class="pa4 shadow-2 br3">Card with medium shadow</div>

<button class="pa3 shadow-1 hover-shadow-3">Lift on hover</button>

Lists

List Styles

Class CSS
.list Reset list styles

Removes default padding and list-style.

List Example

<ul class="list pl0">
  <li class="pv2 bb b--black-10">Item 1</li>
  <li class="pv2 bb b--black-10">Item 2</li>
  <li class="pv2">Item 3</li>
</ul>

Forms

Input Styles

<!-- Text input -->
<input
  type="text"
  class="input-reset ba b--black-20 pa2 mb2 db w-100"
  placeholder="Enter text"
/>

<!-- Focus state -->
<input type="text" class="input-reset ba b--black-20 pa2 focus-black-40" />

<!-- Button -->
<button class="b ph3 pv2 input-reset ba b--black bg-transparent pointer f6 dib">
  Submit
</button>

Input Reset

Class Effect
.input-reset Remove browser defaults

Resets appearance, border, padding, and background.

Aspect Ratios

Aspect Ratio Classes

Class Ratio
.aspect-ratio Container
.aspect-ratio--16x9 16:9
.aspect-ratio--9x16 9:16
.aspect-ratio--4x3 4:3
.aspect-ratio--3x4 3:4
.aspect-ratio--6x4 6:4
.aspect-ratio--4x6 4:6
.aspect-ratio--8x5 8:5
.aspect-ratio--5x8 5:8
.aspect-ratio--7x5 7:5
.aspect-ratio--5x7 5:7
.aspect-ratio--1x1 1:1 (square)
.aspect-ratio--object Child element

Aspect Ratio Example

<div class="aspect-ratio aspect-ratio--16x9">
  <iframe src="video.mp4" class="aspect-ratio--object"> </iframe>
</div>

<div class="aspect-ratio aspect-ratio--1x1">
  <div class="aspect-ratio--object cover" style="background:url(img.jpg)"></div>
</div>

Images

Background Size

Class CSS
.cover background-size: cover
.contain background-size: contain

Background Position

Class CSS
.bg-center background-position: center center
.bg-top background-position: top center
.bg-right background-position: center right
.bg-bottom background-position: bottom center
.bg-left background-position: center left

Background Repeat

Class CSS
.bg-repeat background-repeat: repeat
.bg-no-repeat background-repeat: no-repeat

Image Example

<!-- Responsive image -->
<img src="photo.jpg" class="w-100 db" alt="Photo" />

<!-- Background image -->
<div class="vh-100 cover bg-center" style="background-image: url(bg.jpg)"></div>

Coordinates

Absolute Centering

<!-- Horizontal center -->
<div class="absolute left-0 right-0 center">Horizontally centered</div>

<!-- Vertical and horizontal center -->
<div class="absolute absolute--fill flex items-center justify-center">
  Perfectly centered
</div>

Pin to Corners

<!-- Top-left -->
<div class="absolute top-0 left-0">Top-left</div>

<!-- Top-right -->
<div class="absolute top-0 right-0">Top-right</div>

<!-- Bottom-right -->
<div class="absolute bottom-0 right-0">Bottom-right</div>

<!-- Bottom-left -->
<div class="absolute bottom-0 left-0">Bottom-left</div>

Debugging

Debug Classes

Class Effect
.debug Outline all children
.debug-grid Background grid

Debug Example

<div class="debug">
  <div class="pa2">Box 1</div>
  <div class="pa2">Box 2</div>
</div>

Add to any element to visualize layout.

Common Patterns

Centered Container

<div class="mw7 center ph3">
  <h1>Centered content</h1>
</div>

Flexbox Grid

<div class="flex flex-wrap">
  <div class="w-100 w-50-m w-33-l pa2">
    <div class="bg-light-gray pa3">Column 1</div>
  </div>
  <div class="w-100 w-50-m w-33-l pa2">
    <div class="bg-light-gray pa3">Column 2</div>
  </div>
  <div class="w-100 w-50-m w-33-l pa2">
    <div class="bg-light-gray pa3">Column 3</div>
  </div>
</div>

Hero Section

<header class="vh-100 bg-dark-gray white flex items-center justify-center">
  <div class="tc">
    <h1 class="f1 f-subheadline-l fw7 mb0">Hero Title</h1>
    <p class="f3 fw4 mt3 mb4">Subtitle goes here</p>
    <a href="#" class="f6 link dim br-pill ph4 pv3 mb2 dib white bg-blue">
      Call to Action
    </a>
  </div>
</header>

Button Variants

<!-- Primary button -->
<a class="f6 link dim br-pill ph4 pv3 dib white bg-blue" href="#"> Primary </a>

<!-- Secondary button -->
<a class="f6 link dim br-pill ba ph4 pv3 dib blue" href="#"> Secondary </a>

<!-- Ghost button -->
<a class="f6 link dim br-pill ba bw1 ph4 pv3 dib black" href="#"> Ghost </a>

Navigation

<nav class="dt w-100 border-box pa3 ph5-l">
  <a class="dtc v-mid mid-gray link dim w-25" href="/" title="Home">
    <img src="logo.svg" class="dib w2 h2 br-100" alt="Site Logo" />
  </a>
  <div class="dtc v-mid w-75 tr">
    <a class="link dim dark-gray f6 f5-l dib mr3 mr4-l" href="#" title="About"
      >About</a
    >
    <a class="link dim dark-gray f6 f5-l dib mr3 mr4-l" href="#" title="Work"
      >Work</a
    >
    <a class="link dim dark-gray f6 f5-l dib" href="#" title="Contact"
      >Contact</a
    >
  </div>
</nav>

Footer

<footer class="pv4 ph3 ph5-ns tc">
  <a
    class="link near-black hover-silver dib h2 w2 mr3"
    href="#"
    title="Facebook"
  >
    <svg>...</svg>
  </a>
  <a
    class="link near-black hover-silver dib h2 w2 mr3"
    href="#"
    title="Twitter"
  >
    <svg>...</svg>
  </a>
  <p class="f6 db b ttu lh-solid">Company Name</p>
  <p class="f6 gray mt2 mb3">© 2026 Company. All Rights Reserved</p>
</footer>

Gotchas

Spacing Scale

⚠️ Not linear pixels - Uses powers of two:

  • .pa1 = 4px (not 1px)
  • .pa2 = 8px (not 2px)
  • .pa3 = 16px (not 3px)

Font Sizes

⚠️ .f7 is tiny (12px) - Use with extreme caution. Not recommended for body text.

⚠️ Headlines too large for mobile - Always use responsive variants:

<h1 class="f2 f-subheadline-l">Title</h1>

Responsive Breakpoints

⚠️ Mobile-first, min-width - .dn-ns means hidden at 480px and above, not below.

⚠️ -m is range, not threshold - Medium classes only apply between 480px–960px, not 480px+.

Borders

⚠️ Inherit text color - Borders use currentColor by default. Set explicitly:

<div class="ba b--black-10">Explicit border color</div>

Flexbox

⚠️ .flex-auto includes min-width: 0 - This is a workaround for Chrome's flexbox overflow bug with long content.

Calc() Support

⚠️ .w-third uses calc() - Not supported in Opera Mini or IE8. Use .w-33 for better compatibility.

Performance

⚠️ Shadows can impact performance - Avoid animating .shadow-* classes. Animate transform and opacity instead.

Also see

Tachyons Cheatsheet - NexusCS