• Stars
    star
    201
  • Rank 194,491 (Top 4 %)
  • Language
    JavaScript
  • Created over 5 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Tachyons implemented with emotion and styled-system. Sits on create-react-app.

Tachyons React App [WIP]

This extends create-react-app to include Tachyons implemented with emotion + styled-system. If you're familiar with Tachyons and are interested in css-in-js, this is hopefully a helpful project. Can be used for anything you'd use create-react-app for. While Tachyons is light-weight by default, using css-in-js will result in increased css performance as you don't send unused styles down the wire.

Getting going

Clone the directory and cd into the root of the directory

git clone [email protected]:tachyons-css/tachyons-styled-react.git newProject && cd newProject

Install dependencies

yarn 

Start the dev environment

yarn start

This should start a development environment on localhost:3000

Elements

src/elements/

This folder contains html elements wired up to styled system. Scales are defined and configurable in src/theme.js

Not every element has every styling prop included. For instance I don't find it useful to set fontSize on an img.

Elements can be composed together just like regular html elements to make more complex components.

Pages

Add new pages / routes in src/App.js

You can copy src/pages/Example.js to get a new blank page to work with. Say we wanted to create a view at localhost:3000/new-page and we wanted the page to be called NewPage.

Import it into App.js

// import pages here 
import Styles from './pages/Styles'
import Home from './pages/Home'
import NewPage from './pages/NewPage'

Next add the route you want to use for that page

  <Router>
    <Route exact path='/' component={Home} />
    <Route path='/styles' component={Styles} />
    <Route path='/new-page' component={NewPage} />
  </Router>

Theme

The theme file is 100% configurable. While Tachyons comes with some useful defaults, you can modify, extend, or reduce anything that's there to fit your needs.

Styled system

Styled system is well documented and I suggest checking out the official site over at https://styled-system.com. In short - Styled system allows you to pass arrays of values to style props like color, fontSize, display, and more that map to a consistent set of breakpoints. You can reference scales from a theme file or pass in literal values. The output is a set of single purpose classes for only the styles you need in your view.

I love styled system. I've been using it heavily for the last two years and I think it is a great way to implement Tachyons. While many people think of Tachyons as a css file, I think of it as a project. A whole bunch of modular ideas with a common set of principals.

The main Tachyons repo includes a bunch of terse naming schemes for a lot of the classes, but that was never a core part of the project, which is why thanks to @hongkonggong there has been a verbose version with longer class names we've supported. While the main version was built with postcss, we've long supported a sass build as well. The stack has never been the point. Tachyons for me have been centered around pushing the envelope in css performance for both rendering and download speed while testing the relationships between values in design primitives.

While trying to keep Tachyons small - it's important to limit things like how large the color palette is. For every color there were corresponding border,:hover,:focus classes. With styled-system and emotion this isn't an issue. You can keep a more verbose color palette, without automatically creating a larger css foot-print. The only css that's generated is for the styles you are using. While some people use something to strip out unused styles, I think this model makes more sense and is less error prone.

While personally I don't have too much trouble parsing the same property being spread out in a class string e.g. "f2 db di-ns f3-m f4-l" I think it's a lot nicer to have properties automatically grouped together. You also aren't dealing with repetitive name spacing in the class names e.g f6 f4-ns f3-l Each f is just indicating it's the font size property. I don't think I'm going out on a limb to say that this is ~1000x nicer fontSize={[3,4,6]}

If the transition to javascript style syntax scares you a bit, I can absolutely relate. I am very limited in my javascript ability and this project is partly a reflection of all the stuff I wish I had setup 2 years ago when I first started to almost explicitly work in codebases that used a css-in-js solution for styling. If you know html and css - I hope this serves as a gateway to play with react and css-in-js a bit. It's currently my favorite way to use Tachyons.

Reference

More Repositories

1

tachyons

Functional css for humans
CSS
11,587
star
2

react-native-style-tachyons

Better styling for React Native
TypeScript
689
star
3

tachyons-sass

Transpiled Sass partials for Tachyons
SCSS
318
star
4

generator

Generate a custom Tachyons build from a config file
JavaScript
317
star
5

tachyons-custom

Tachyons with variables: for easy customization
CSS
203
star
6

tachyons-tldr

quick lookup for tachyon classes, scales and colour palette
JavaScript
181
star
7

tachyons-and-react

[WIP] Documentation on using Tachyons and React together
JavaScript
119
star
8

tachyons-verbose

Functional CSS for humans. Verbose edition.
CSS
107
star
9

tachyons-webpack

A boilerplate for using tachyons with webpack
JavaScript
80
star
10

jekyll-tachyons

Jekyll + Tachyons Boilerplate
CSS
79
star
11

tachyons-css.github.io

Documentation for designing faster than the speed of light
HTML
77
star
12

cli

Cli to postprocess tachyons stylesheets and generate documentation
JavaScript
76
star
13

tachyons-box-sizing

Module moved to the Tachyons monorepo
CSS
40
star
14

tachyons-flexbox

Module moved to the Tachyons monorepo
CSS
40
star
15

tachyons-x-ray

Browser extension for tachyons-debug
JavaScript
29
star
16

tachyons-build-css

Transpile Tachyons postcss to vanilla css
JavaScript
27
star
17

tachyons-theme-ui

Theme UI implementation of Tachyons
JavaScript
25
star
18

tachyons-system

Tachyons theme for styled-system http://jxnblk.com/styled-system
JavaScript
24
star
19

tachyons-amp

Stripped down version of Tachyons for developing with Google AMP
CSS
18
star
20

tachyons-debug-grid

Module moved to the Tachyons monorepo
17
star
21

tachyons-typography

Module moved to the Tachyons monorepo
CSS
13
star
22

tachyons-spacing

Module moved to the Tachyons monorepo
CSS
13
star
23

tachyons-hovers

Module moved to the Tachyons monorepo
CSS
11
star
24

tachyons-colors

Module moved to the Tachyons monorepo
CSS
10
star
25

palette-generator

JavaScript
10
star
26

tachyons-forms

Module moved to the Tachyons monorepo
HTML
9
star
27

tachyons-queries

Custom media query variables for rework
JavaScript
9
star
28

tachyons-skins

Module moved to the Tachyons monorepo
CSS
9
star
29

tachyons-aspect-ratios

Module moved to the Tachyons monorepo
CSS
7
star
30

tachyons-modules

Get a list of all Tachyons CSS modules
JavaScript
7
star
31

tachyons-links

Module moved to the Tachyons monorepo
CSS
7
star
32

tachyons-display

Module moved to the Tachyons monorepo
CSS
7
star
33

tachyons-cms

CSS
7
star
34

tachyons-base

Module moved to the Tachyons monorepo
CSS
7
star
35

tachyons-z-index

Module moved to the Tachyons monorepo
CSS
6
star
36

tachyons-utilities

Module moved to the Tachyons monorepo
CSS
5
star
37

tachyons-negative-margins

Module moved to the Tachyons monorepo
CSS
5
star
38

tachyons-type-scale

Module moved to the Tachyons monorepo
CSS
5
star
39

tachyons-opacity

Module moved to the Tachyons monorepo
CSS
5
star
40

tachyons-docs

(WIP) React Documentation website for tachyons modules and components
JavaScript
4
star
41

tachyons-display-verbose

CSS
4
star
42

tachyons-widths

Module moved to the Tachyons monorepo
CSS
3
star
43

tachyons-skins-pseudo

Module moved to the Tachyons monorepo
CSS
3
star
44

tachyons-border-colors

Module moved to the Tachyons monorepo
CSS
3
star
45

tachyons-visibility

Module moved to the Tachyons monorepo
CSS
3
star
46

tachyons-debug

Module moved to the Tachyons monorepo
CSS
3
star
47

tachyons-borders

Module moved to the Tachyons monorepo
CSS
2
star
48

tachyons-tables

Module moved to the Tachyons monorepo
CSS
2
star
49

tachyons-background-size

Module moved to the Tachyons monorepo
CSS
2
star
50

tachyons-coordinates

Module moved to the Tachyons monorepo
CSS
2
star
51

tachyons-background-position

Module moved to the Tachyons monorepo
CSS
2
star
52

tachyons-text-align

Module moved to the Tachyons monorepo
CSS
2
star
53

tachyons-text-transform

Module moved to the Tachyons monorepo
CSS
2
star
54

tachyons-border-widths

Module moved to the Tachyons monorepo
CSS
2
star
55

tachyons-font-family

Module moved to the Tachyons monorepo
CSS
2
star
56

tachyons-box-shadow

Module moved to the Tachyons monorepo
CSS
2
star
57

tachyons-images

Module moved to the Tachyons monorepo
CSS
1
star
58

tachyons-heights

Module moved to the Tachyons monorepo
CSS
1
star
59

img

Images for the tachyons docs
1
star
60

tachyons-text-decoration

Module moved to the Tachyons monorepo
CSS
1
star
61

tachyons-outlines

Module moved to the Tachyons monorepo
CSS
1
star
62

tachyons-border-style

Module moved to the Tachyons monorepo
CSS
1
star
63

tachyons-border-radius

Module moved to the Tachyons monorepo
CSS
1
star
64

tachyons-floats

Module moved to the Tachyons monorepo
CSS
1
star
65

tachyons-rotations

Module moved to the Tachyons monorepo
CSS
1
star
66

tachyons-word-break

Module moved to the Tachyons monorepo
CSS
1
star
67

tachyons-line-height

Module moved to the Tachyons monorepo
CSS
1
star
68

tachyons-max-widths

Module moved to the Tachyons monorepo
CSS
1
star
69

tachyons-clears

Module moved to the Tachyons monorepo
CSS
1
star
70

tachyons-vertical-align

Module moved to the Tachyons monorepo
CSS
1
star
71

tachyons-styles

Empty partial for extending tachyons styles
SCSS
1
star