React Native Random color pair generator

I am trying to generate a palette which would have an array of color pairs (lighter/darker) and check whether it doesn’t have duplicates. I have checked Martin’s color generation and several libraries like random color generator npm, but I don’t quite understand how to generate a pair of similar shade colors. Taking for example these two colors:

light
dark

How to achieve same result but with a random color generator?

12 thoughts on “React Native Random color pair generator”

  1. Found an answer by using Random color and Chroma js. Something like this:

        for (let i = 0; i < NUM_OF_COLORS; i++) {
        colorsLight[i] = randomColor({
            luminosity: "bright",
            format: "rgba",
            alpha: 0.6,
        });
        colorsDark[i] = chroma(colorsLight[i]).alpha(0.3).hex();
    

    I generate two arrays of colors, but it can easily be put into one and used as a pair of beautiful dark/light colors.

    Reply

Leave a Comment