TypeStyle

Making CSS Typesafe

README

TypeStyle

Join the chat at  gitter

Making CSS type safe.

[![Build Status][travis-image]][travis-url] [![NPM version][npm-image]][npm-url] Downloads

Writing CSS with TypeStyle will be just as fluent as writing JavaScript with TypeScript.

undefined

There are quite a few css in js frameworks out there. This one is different:

- Provides great TypeScript developer experience.
- No custom AST transform or module loader support needed.
- Works with any framework (react, angular2, cyclejs, whatever, doesn't matter).
- Zero config. Just use.
- super small (~6k gz)

This project is powered by github 🌟s ^ go ahead and star it please.


Checkout [the awesome list of reviews 🌹][reviews].

Overview



Quickstart


Use it like you would use CSS modules or CSS in general with webpack etc, but this time you get to use TypeScript / JavaScript!

Install
npm install typestyle --save

Use
  1. ```tsx
  2. /** Import */
  3. import {style} from "typestyle";

  4. /** convert a style object to a CSS class name */
  5. const className = style({color: 'red'});

  6. /** Use the class name in a framework of choice */
  7. //  e.g. React
  8. const MyButton =
  9.   ({onClick,children})
  10.     => <button className={className} onClick={onClick}>
  11.         {children}
  12.       </button>
  13. // or Angular2
  14. @Component({
  15.   selector: 'my-component',
  16.   template: `<div class="${className}">Tada</div>`
  17. })
  18. export class MyComponent {}
  19. ```

Guide

We really really want to make CSS maintainable and simple. So we even wrote a free and open source book, covering the super simple core API, a handful of utility styles in [csx](https://github.com/typestyle/csx) and tons of other goodness 🌹. [Jump to the guide][book]
[undefined][book]


Video Course

The guide contains everything you need to know. But if you prefer to watch video [we have a free course up on egghead][course].
[undefined][course]


Why

You are probably here cause you are unhappy with your current workflow. So why not just jump to the [guide][book] and give it a go. If you [still need reasons we have quite a few][why].

[free-style]:https://github.com/blakeembrey/free-style
[travis-image]:https://travis-ci.org/typestyle/typestyle.svg?branch=master
[travis-url]:https://travis-ci.org/typestyle/typestyle
[npm-image]:https://img.shields.io/npm/v/typestyle.svg?style=flat
[npm-url]:https://npmjs.org/package/typestyle
[types.ts]:https://github.com/typestyle/typestyle/blob/master/src/types.ts
[csx]:https://github.com/typestyle/typestyle#csx
[book]:https://typestyle.github.io
[course]:https://egghead.io/courses/maintainable-css-using-typestyle
[why]:https://typestyle.github.io/#/why
[reviews]:https://typestyle.github.io/#/reviews