1.0.0 • Published 10 years ago

ng-style v1.0.0

Weekly downloads
4
License
MIT
Repository
github
Last release
10 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

10 years ago

0.0.7

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago