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
100
Quality
88
Maintenance
100
Vulnerability
100
License
TypeScript (99.84%)
JavaScript (0.16%)
Total Downloads
66,504,384
Last Day
240,739
Last Week
4,884,274
Last Month
20,655,699
Last Year
66,502,876
MIT License
1 Stars
321 Commits
1 Forks
2 Watchers
1 Branches
3 Contributors
Updated on Jun 28, 2025
Minified
Minified + Gzipped
Latest Version
3.2.0
Package Id
@asamuzakjp/css-color@3.2.0
Unpacked Size
2.00 MB
Size
378.12 kB
File Count
58
NPM Version
11.4.0
Node Version
22.15.1
Published on
May 20, 2025
Cumulative downloads
Total Downloads
Last Day
12.9%
240,739
Compared to previous day
Last Week
-3.6%
4,884,274
Compared to previous week
Last Month
16.6%
20,655,699
Compared to previous month
Last Year
4,409,905%
66,502,876
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 = covert.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.
No security vulnerabilities found.