random-gradient

Generate beautiful random gradients

MIT License

Downloads
2K
Stars
71
Committers
4

random-gradient Build Status

Generate beautiful random gradients

Install

$ npm install --save random-gradient

Usage

// with React

import gradient from 'random-gradient'

export default ({ name }) => {
  const bgGradient = { background: gradient(name) }

  return (
    <div style={bgGradient}>
      <h2>{name}</h2>
    </div>
  )
}

// with Vue

import gradient from 'random-gradient'

Vue.directive('random-gradient', {
    inserted: function (el) {
        // Using the element's "title" attribute, e.g.
        el.style.backgroundImage = gradient(el.title);
    }
});

API

randomGradient(uid, type)

uid

Type: string Required

type

Type: string Default: diagonal Options: diagonal, vertical, horizontal, radial

Related

License

MIT © Bu Kinoshita

Package Rankings
Top 5.26% on Npmjs.org
Badges
Extracted from project README
Build Status