string-to-color-react
v1.0.3
Published
Generates a hexadecimal color depending on the input string, also allows passing default colors/schema
Downloads
3
Readme
String to color React
Generates a hexadecimal color depending on the input string, also allows passing default colors/schema.
Install
npm install string-to-color-react
yarn add string-to-color-react
Demo
Link: https://demo-string-to-color-react-bvecj2wl7-lukke-dev.vercel.app/
Usage
import { generateColorFromString } from 'string-to-color-react'
const primary = generateColorFromString('foo') // => "#c68c01"
const secondary = generateColorFromString('name') // => "#8b7a33"
or pass an array of options, like a schema!
import { generateColorFromString } from 'string-to-color-react'
const schemaOptions = ['red', 'green', 'teal', 'yellow']
const color = generateColorFromString('foo', schemaOptions) // => "teal"
const color = generateColorFromString('name', schemaOptions) // => "yellow"
License
MIT.