1.0.0 • Published 8 years ago

ng-style v1.0.0

Weekly downloads
4
License
MIT
Repository
github
Last release
8 years ago

ng-style Build Status

Write inline styles for Angular

Takes a style object, prefixes it, and converts it to a CSS string.

Great for use with the angular inline styles array.

Install

$ npm install --save ng-style

Usage

my-component.ts

import {Component} from '@angular/core'
import styles from './styles'

@Component({
  selector: 'my-component',
  template: '<h1>Hello!</h1>'
  styles: [styles]
})
class MyComponent {}

styles.ts

import ngStyles from 'ng-styles'
import Color from 'color'

export default ngStyles({
  h1: {
    fontSize: '20px',
    color: 'black',
    transition: 'color 250ms' // will be prefixed
  },
  'h1:hover': {
    color: Color('red').alpha(0.5).rgbaString()
  },
})

API

ngStyle(object) -> cssString

object

Required Type: object

An object representing css styles. Allows camelCase style keys.

See to-css for documentation on how to javascript styles in css.

Returns a valid css string.

License

MIT © Andrew Joslin

1.0.0

8 years ago

0.0.7

8 years ago

0.0.6

8 years ago

0.0.5

8 years ago

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago