magic-color ![NPM version](https://img.shields.io/npm/v/magic-color?color=a1b858&label=)
Magic color creator.
Features
- 🎨 Convert between RGB, HEX, HSL and HSB.
- 🦄 Theme color generator.
- etc.
Usage
pnpm add magic-color
A lot of color tool functions for you to use, providing easy conversion, generation, parsing, comparison, operation and other functions.
Example
import { hexTorgb, rgbTohex } from 'magic-color'
hexTorgb('#fff')
rgbTohex('rgb(255, 255, 255)')
And more...
theme
Well, you can use it to create a theme color.
import { theme } from 'magic-color'
theme('#9955ff')
And you can custom it with themeOptions
.
export interface ThemeOptions {
type?: ColorType
render?: (meta: [string, string]) => [string, string]
}
import { theme } from 'magic-color'
theme('#9955ff', {
type: 'rgb',
render: (meta) => {
return [
`--color-primary-${meta[0]}`,
meta[1].replace(/rgb\((.*)\)/, '$1').replace(/,/g, ''),
]
},
})
Credits
license
MIT