Simple utility to generate flat colors, colors are taken from : https://flatuicolors.com/
sometimes, for example when generating dynamic charts without knowing the number of items, is useful to generate aesthetically-pleasing colors and that go well together.
npm i flat-colors-js
then import in your project ex. in react
import { getColor,getPalette } from 'flat-colors-js'
or in node
const {getColor,getPalette} = require("flat-colors-js")
getColor(palette,index,rgb)
return a random (or not) color, it has 3 optional params:
- palette : string, default
false
, if specified return a color of the given palette, see below for all avaible palettes. - index : int, default
false
, if specified return the color at the given index (usefull in loops) - rgb : boolean, default
false
, if true return color value as rgb (default is Hex)
getPalette(palette)
return an array with the colors of the given palette.
let randomColor = getColor()
return a random color from a random palette.
let randomColor = getColor("chinese_palette")
return a random color from chinese palette.
let randomColor = getColor("chinese_palette",2)
return the second color of chinese palette.
let randomColor = getColor("chinese_palette",2,true)
return second color of chinese palette as rgb.
default : https://flatuicolors.com/
german_palette : https://flatuicolors.com/palette/de
spanish_palette : https://flatuicolors.com/palette/es
aussie_palette : https://flatuicolors.com/palette/au
russian_palette : https://flatuicolors.com/palette/ru
american_palette : https://flatuicolors.com/palette/us
chinese_palette : https://flatuicolors.com/palette/cn
british_palette : https://flatuicolors.com/palette/gb
dutch_palette : https://flatuicolors.com/palette/nl
turkish_palette : https://flatuicolors.com/palette/tr
indian_palette : https://flatuicolors.com/palette/in
canadian_palette : https://flatuicolors.com/palette/ca
swedish_palette : https://flatuicolors.com/palette/se
frensh_palette : https://flatuicolors.com/palette/fr