Skip to content

Commit

Permalink
Update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
frenic committed Feb 7, 2018
1 parent 9bf9714 commit e48d1c5
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,21 @@ const style: CSS.Properties = {

## Getting started

```bash
$ npm install csstype@latest # For projects
$ npm install csstype@* # For libraries
```sh
$ npm install csstype
$ # or
$ yarn add csstype
```

## Usage

Lengths defaults to `string`. But it's possible to add `number` as well using generics.
Lengths defaults to `string | number`. But it's possible to override it using generics.

```ts
import * as CSS from 'csstype';

const style: CSS.Properties<string | number> = {
padding: 10,
const style: CSS.Properties<string> = {
padding: '10px',
margin: '1rem',
}
```
Expand Down Expand Up @@ -56,3 +57,18 @@ const pseudos: { [P in CSS.Pseudos]?: CSS.Properties } = {
},
}
```

Hyphen cased (kebab cased) properties are provided in `CSS.PropertiesHyphen` and `CSS.PropertiesHyphenFallback`. It's not **not** added by default in `CSS.Properties`. To allow both of them, you can simply extend with `CSS.PropertiesHyphen` or/and `CSS.PropertiesHyphenFallback`.

```ts
import * as CSS from 'csstype';

interface Style extends CSS.Properties, CSS.PropertiesHyphen { }

const style: Style = {
'flex-grow': 1,
'flex-shrink': 0,
'font-weight': 'normal',
backgroundColor: 'white',
}
```

0 comments on commit e48d1c5

Please sign in to comment.