New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

niram

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

niram

A javascript library to convert between various css colour formats.

latest
Source
npmnpm
Version
0.1.6
Version published
Maintainers
1
Created
Source

Niram

A javascript library to convert between various css colour formats.

Installation

Install niram using any of the command below

  • yarn add niram
  • npm install niram

Usage

To convert colours:

import { convertColor } from 'niram'

const color = convertColor('hsl(120deg, 100%, 25%)')

console.log(color)

Above code will log the converted colour details to console as:

{
    "name": "green",
    "decimal": 8388863,
    "hex": "#008000",
    "rgb": "rgb(0, 128, 0)",
    "rgba": "rgba(0, 128, 0, 1)",
    "hsl": "hsl(120deg, 100%, 25%)",
    "hsla": "hsla(120deg, 100%, 25%, 1)",
    "opacity": 1
}

To validate colours:

import { validateColor } from 'niram'

const isColorValid = validateColor('hwb(120deg 0% 50% / 1)')

console.log(isColorValid)

// Outputs: true

Supported Formats

Following are the supported colour formats (given with example)

  • Colour Keywords - green

  • HEX - #008000 or #0f0

  • RGB - rgb(0, 128, 0) or rgb(0 128 0)

  • RGBA - rgba(0, 128, 0, 1) or rgba(0 128 0 / 1)

  • HSL* - hsl(120deg, 100%, 25%) or hsl(120deg 100% 25%)

  • HSLA* - hsla(120deg, 100%, 25%, 1) or hsla(120deg 100% 25% / 1)

  • HWB*# - hwb(120deg 0% 50% / 1)

  • LAB# - lab(46.23 -51.7 49.9 / 1)

  • LCH# - lch(46.28% 67.98 134.38 / 1)

* You can also use rad instead of deg

# Support is only available for Validation

Unsupported Formats

Following are currently unsupported for conversion, but support will be added soon.

  • hwb()
  • lab()
  • lch()

Keywords

css-color-converter

FAQs

Package last updated on 06 Apr 2025

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