1.0.3 • Published 6 years ago

angular-randomcolor v1.0.3

Weekly downloads
181
License
ISC
Repository
-
Last release
6 years ago

angular-randomcolor

Simple library where you can generate random colors.

Installation

  • In order to install it you need to run
npm i angular-randomcolor --save
  • Add it to your app.module
import { RandomcolorModule } from 'angular-randomcolor';

imports: [
    RandomcolorModule
]

NOTE

Yo do not have to import the RandomcolorModule if you are using the library just for generating the color in your .ts (see Usage 1)


Usage 1

Generate a random hexadecimal color is simple:

import { RandomColor } from 'angular-randomcolor';
...
const newColor = RandomColor.generateColor()

Usage 2

You can randomize your text and/or background color directly in your HTML:

<div class="box" rcRandomColor [bgColor]="['red', 'blue']" [textColor]="[]"></div>
  • bgColor will randomize your background color. (optional)
  • textColor will randomize your text color. (optional)

You can pass an empty array so the color will be generate randomly or you can use your own color array so it will pick one of those randomly.