Gathering detailed insights and metrics for @asamuzakjp/css-color
Gathering detailed insights and metrics for @asamuzakjp/css-color
Gathering detailed insights and metrics for @asamuzakjp/css-color
Gathering detailed insights and metrics for @asamuzakjp/css-color
npm install @asamuzakjp/css-color
Typescript
Module System
Node Version
NPM Version
99.1
Supply Chain
97.9
Quality
90.3
Maintenance
100
Vulnerability
100
License
TypeScript (99.84%)
JavaScript (0.16%)
Built with Next.js • Fully responsive • SEO optimized • Open source ready
Total Downloads
109,094,406
Last Day
315,491
Last Week
6,677,333
Last Month
26,934,988
Last Year
109,092,226
MIT License
1 Stars
335 Commits
1 Forks
2 Watchers
1 Branches
3 Contributors
Updated on Aug 03, 2025
Latest Version
4.0.4
Package Id
@asamuzakjp/css-color@4.0.4
Unpacked Size
2.06 MB
Size
388.77 kB
File Count
58
NPM Version
11.4.2
Node Version
22.16.0
Published on
Aug 03, 2025
Cumulative downloads
Total Downloads
Last Day
1.4%
315,491
Compared to previous day
Last Week
0.6%
6,677,333
Compared to previous week
Last Month
14.6%
26,934,988
Compared to previous month
Last Year
5,004,130.6%
109,092,226
Compared to previous year
Resolve and convert CSS colors.
1npm i @asamuzakjp/css-color
1import { convert, resolve, utils } from '@asamuzakjp/css-color'; 2 3const resolvedValue = resolve( 4 'color-mix(in oklab, lch(67.5345 42.5 258.2), color(srgb 0 0.5 0))' 5); 6// 'oklab(0.620754 -0.0931934 -0.00374881)' 7 8const convertedValue = convert.colorToHex('lab(46.2775% -47.5621 48.5837)'); 9// '#008000' 10 11const result = utils.isColor('green'); 12// true
resolves CSS color
color
string color value
opt
object? options (optional, default {}
)
opt.currentColor
string?
currentcolor
keywordrgb(none none none / none)
opt.customProperty
object?
--
prefixed property name as a key and it's value,
e.g.
1const opt = { 2 customProperty: { 3 '--some-color': '#008000', 4 '--some-length': '16px' 5 } 6};
callback
function to get the value of the custom property,
e.g.
1const node = document.getElementById('foo'); 2const opt = { 3 customProperty: { 4 callback: node.style.getPropertyValue 5 } 6};
opt.dimension
object?
1em === 12px
, 1rem === 16px
and 100vw === 1024px
, then
1const opt = { 2 dimension: { 3 em: 12, 4 rem: 16, 5 vw: 10.24 6 } 7};
callback
function to get the value as a number in pixels,
e.g.
1const opt = { 2 dimension: { 3 callback: unit => { 4 switch (unit) { 5 case 'em': 6 return 12; 7 case 'rem': 8 return 16; 9 case 'vw': 10 return 10.24; 11 default: 12 return; 13 } 14 } 15 } 16};
opt.format
string?
computedValue
(default), computed value of the colorspecifiedValue
, specified value of the colorhex
, hex color notation, i.e. #rrggbb
hexAlpha
, hex color notation with alpha channel, i.e. #rrggbbaa
Returns string? one of rgba?()
, #rrggbb(aa)?
, color-name
, color(color-space r g b / alpha)
, color(color-space x y z / alpha)
, (ok)?lab(l a b / alpha)
, (ok)?lch(l c h / alpha)
, '(empty-string)'
, null
computedValue
, values are numbers, however rgb()
values are integersspecifiedValue
, returns empty string
for unknown and/or invalid colorhex
, returns null
for transparent
, and also returns null
if any of r
, g
, b
, alpha
is not a numberhexAlpha
, returns #00000000
for transparent
, however returns null
if any of r
, g
, b
, alpha
is not a numberContains various color conversion functions.
convert number to hex string
value
number color valueReturns string hex string: 00..ff
convert color to hex
Returns string #rrggbb(aa)?
convert color to hsl
Returns Array<number> [h, s, l, alpha]
convert color to hwb
Returns Array<number> [h, w, b, alpha]
convert color to lab
Returns Array<number> [l, a, b, alpha]
convert color to lch
Returns Array<number> [l, c, h, alpha]
convert color to oklab
Returns Array<number> [l, a, b, alpha]
convert color to oklch
Returns Array<number> [l, c, h, alpha]
convert color to rgb
Returns Array<number> [r, g, b, alpha]
convert color to xyz
Returns Array<number> [x, y, z, alpha]
convert color to xyz-d50
Returns Array<number> [x, y, z, alpha]
Contains utility functions.
is valid color type
color
string color value
Returns boolean
The following resources have been of great help in the development of the CSS color.
Copyright (c) 2024 asamuzaK (Kazz)
No vulnerabilities found.