Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

angular-randomcolor

guiroco548ISC1.0.3TypeScript support: included

Simple library where you can generate random colors.

angular, color, random, libary, hexadecimal, directive, angular 2, angular 4, angular 5, angular 6

readme

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 `typescript 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))

---

## Usage 1
Generate a random **hexadecimal** color is simple:

```typescript
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.