Socket
Socket
Sign inDemoInstall

random-colors-palette

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

random-colors-palette

It allows you to generate random colors from a set of palettes defined by material io.


Version published
Maintainers
1
Created
Source

Javascript: random-colors-palette

GitHub package version github home github home npm

github issues github closed issues Issue Stats github license

It allows you to generate random colors from a set of palettes defined by material io.

💻 Usage

import { uniqColor, randomColor, colorsList, huesList, shadesList, formatList } from 'random-colors-palette';

uniqColor()

/*
text = new Date()
*/

uniqColor({ format: "hex" });

/*
text = new Date()
*/

uniqColor({ text: "", format: "hsl" });

/*
text = new Date()
*/

uniqColor({ text: "Hello world!", format: "rgb" });

/*
[
    {
        "hue": "cyan",
        "shade": "100",
        "value": "rgb(178, 235, 242)"
    }
]
*/

uniqColor({ text: ["Hello", "wold", "!"], format: "hex" });

/*
[
    {
        "hue": "orange",
        "shade": "600",
        "value": "#fb8c00"
    },
    {
        "hue": "lightBlue",
        "shade": "A400",
        "value": "#00b0ff"
    },
    {
        "hue": "deepOrange",
        "shade": "700",
        "value": "#e64a19"
    }
]
 */

randomColor({
 number: 3,
 hues: ['red', 'blue', 'lightBlue', 'cyan'],
 shades: ['100', '300', '400', '500', '700'],
 excludeHues: ['red'],
 excludeShades: ['400'],
 repeat: false,
 numberColorGroup: 1,
 format: 'hex',
 typeObj: true
});

/*
{
    "combination": 12,
    "color": [
        {
            "hue": "cyan",
            "shade": "300",
            "value": "#4dd0e1"
        },
        {
            "hue": "blue",
            "shade": "100",
            "value": "#bbdefb"
        },
        {
            "hue": "lightBlue",
            "shade": "300",
            "value": "#4fc3f7"
        }
    ],
    "numberGroup": 1
}
*/

randomColor({
 number: 3,
 hues: ['red', 'blue', 'lightBlue', 'cyan'],
 shades: ['100', '300', '400', '500', '700'],
 excludeHues: ['red'],
 excludeShades: ['400'],
 repeat: false,
 numberColorGroup: 2,
 format: 'hls',
 typeObj: true
});

/*
{
    "combination": 12,
    "color": [
        [
            {
                "hue": "cyan",
                "shade": "100",
                "value": "hsl(187, 71.1%, 82.4%)"
            },
            {
                "hue": "lightBlue",
                "shade": "700",
                "value": "hsl(201, 98.1%, 41.4%)"
            }
        ],
        [
            {
                "hue": "lightBlue",
                "shade": "300",
                "value": "hsl(199, 91.3%, 63.9%)"
            }
        ]
    ],
    "numberGroup": 2
}
*/

randomColor({
 number: 3,
 hues: ['red', 'blue', 'lightBlue', 'cyan'],
 shades: ['100', '300', '400', '500', '700'],
 excludeHues: ['red'],
 excludeShades: ['400'],
 repeat: false,
 numberColorGroup: 1,
 format: 'rgb',
 typeObj: false
});

/*
{
    "combination": 12,
    "color": [
        "rgb(77, 208, 225)",
        "rgb(179, 229, 252)",
        "rgb(187, 222, 251)"
    ],
    "numberGroup": 1
}
*/


/* huesList 
[
    'red',
    'pink',
    'purple',
    'deepPurple',
    'indigo',
    'blue',
    'lightBlue',
    'cyan',
    'teal',
    'green',
    'lightGreen',
    'lime',
    'yellow',
    'amber',
    'orange',
    'deepOrange',
    'brown',
    'grey',
    'blueGrey'
]
*/

/* shadesList
[
    '50',
    '100',
    '200',
    '300',
    '400',
    '500',
    '600',
    '700',
    '800',
    '900',
    'A100',
    'A200',
    'A400',
    'A700'
]
*/

/* formatList 
['hex', 'rgb', 'hsl']
*/

💡 Props

uniqColor

PropTypeDefaultNote
textstring/arraynew Date()The text you want to pass to generate the color.
formatstringhexhex, rgb, hsl
textContrastbooltrueIf true, it returns the contrast color to use for the texts.
typeObjbooltrueIf you want the returned value is only an object or the color value.

randomColor

PropTypeDefaultNote
numbernumber1Numbers of colors to generate.
huesarrayhuesListThe hues you want to use to generate the colors.
shadesarrayshadesListThe shades that you want to use to generate the colors.
excludeHuesarray[]The hues you don't want to use to generate colors.
excludeShadesarray[]The shades that you don't want to use to generate the colors.
repeatboolfalseIf you want the colors repeated.
numberColorGroupnumber1If you want the colors to be grouped by n.
formatstringhexhex, rgb, hsl
textContrastbooltrueIf true, it returns the contrast color to use for the texts.
typeObjbooltrueIf you want the returned value is only an object or the color value.

📜 License

This library is provided under the Apache License.

Keywords

FAQs

Package last updated on 07 May 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc