
The random colors generated from randomColor.js are attractive and beautiful and can be used to colorize backgrounds, create buttons, or really anything that stands out. It takes the guesswork out of creating a nice color scheme for your next project.
How
to use it:
1. Install & import the randomColor.js.
# NPM $ npm i randomcolor
// CommonJS
var randomColor = require('randomcolor');
// CDN
<script src="https://cdn.jsdelivr.net/npm/randomcolor@0.6.2/randomColor.min.js"></script>
2. Generate a random color (hex).
randomColor(); // => #ff0000
3. Specify the number of colors to generate.
randomColor({
count: 20
});
4. Set the hue of the colors: red, orange, yellow, green, blue, purple, pink, or monochrome.
randomColor({
hue: 'red',
});
5. Set the luminosity of the colors: bright, light, or dark.
randomColor({
luminosity: 'dark',
});
6. Set the color format: rgb, rgba, rgbArray, hsl, hsla, hslArray, or hex
randomColor({
format: 'rgba',
});
7. Set the alpha channel, which specifies the opacity for an RGBA or HSLA color.
randomColor({
alpha: 0.5,
});
8. Set the seed (seed) that will cause randomColor to return the same color each time.
randomColor({
seed: 3,
});
Changelog:
v0.6.2 (12/03/2025)
- Fix the seeded serie
- refactor: move to ES module
- Dart port for randomColor
- Adding Ruby Gem to the list of ports
- Add Kotlin Port
- Adding TypeScript Definition
- Fixing unstable generation from the same seed
- Rewrote the HexToHSB function
- fix issue with negative hues
The post Tiny Random Color Generator In JavaScript – randomColor.js appeared first on CSS Script.
Discover more from RSS Feeds Cloud
Subscribe to get the latest posts sent to your email.
