🌜
🌞
typestyle

typestyle

v2.4.0

TypeSafe CSS

npm install typestyle

README

TypeStyle

Join the chat at  gitter

Making CSS type safe.

Build Status NPM version Downloads

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

typestyle

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 🌹.

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

/** Import */
import {style} from "typestyle";

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

/** Use the class name in a framework of choice */
//  e.g. React
const MyButton =
  ({onClick,children})
    => <button className={className} onClick={onClick}>
        {children}
      </button>
// or Angular2
@Component({
  selector: 'my-component',
  template: `<div class="${className}">Tada</div>`
})
export class MyComponent {}

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 and tons of other goodness 🌹. *Jump to the guide*

guide

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.

video course

Why

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

Release Notes

1.2.0
By Christopher Wallis • Published on February 18, 2017

This release updates to the latest version of free-style. This version allows for using $nest in normal cssRule() and includes css rules in css de-duplication.

0.7.0
By Basarat Ali Syed • Published on November 13, 2016
  • Instead of import * as csx from 'typestyle/csx' you now need to do import * as csx from 'typestyle/lib/csx' this is because previously we made you recompile csx and now we ship the compiled .js files

Key reasons for doing this change:

  • work with ts-loader
  • preserves outDir option for nodejs users
  • The definition .d.ts files are picked up by the ts compiler instead of .ts and so you can use the strictest TypeScript features without having to also recompile our code.

General

License
MIT
Typescript Types
Built-in
Tree-shakeable
Yes

Popularity

GitHub Stargazers
3,002
Community Interest
3,076
Number of Forks
86

Maintenance

Commits
10/219/2204
Last Commit
Open Issues
22
Closed Issues
189
Open Pull Requests
2
Closed Pull Requests
50

Versions

Versions Released
10/219/2201
Latest Version Released
Aug 1, 2022
Current Tags
latest2.4.0

Dependencies

Contributors

basarat
basarat
Commits: 75
notoriousb1t
notoriousb1t
Commits: 33
greenkeeper[bot]
greenkeeper[bot]
Commits: 33
markvandenbrink
markvandenbrink
Commits: 9
bradleyayers
bradleyayers
Commits: 7
codeandcats
codeandcats
Commits: 2
devdoomari
devdoomari
Commits: 2
pelotom
pelotom
Commits: 2
carloslfu
carloslfu
Commits: 1
swcho
swcho
Commits: 1
aksharpatel47
aksharpatel47
Commits: 1
ShogunPanda
ShogunPanda
Commits: 1
magnushiie
magnushiie
Commits: 1
anion155
anion155
Commits: 1
wmaurer
wmaurer
Commits: 1