hsl.scss

1.0.1 • Public • Published

hsl.scss

HSL colors are awesome. Unfortunately, the SASS hsl() and hsla() functions converts the colors to RGB/RGBA format.

hsl.scss replaces the two SASS functions by two others, preserving HSL(A) color declarations.

Installation

  1. npm install hsl.scss pulls the package into your project.
  2. @import '~hsl.scss'; in a SCSS files make hsl() and hsla() available.

Usage

Write regular CSS, the syntax is exactly the same:

:root {

  // hsl()
  color: hsl(15deg, 100%, 50%);

  // separator: coma (`,`)
  --flashy-pink: hsl(15deg, 100%, 50%);

  // separator: space
  $flashy-pink: hsl(15deg 100% 50%);

  // hsl() accepts opacity as fourth parameter          👇
  --hue: 15deg;
  --transparent-flashy-pink: hsl(var(--hue), 100%, 50%, .7);

  // hsla()
  $transparent-flashy-pink: hsla(15deg, 100%, 50%, .7); 

  // hsla(): opacity after a slash (`/`) when separator is a space
  $transparent-flashy-pink: hsla(15deg 100% 50% / .7);
}

Before / after hsl.scss

Before: lot of issues. Now: no issues anymore.

Before: boring interpolation. Now: standard CSS.

Note

There’s currently no test enforcing the validity of what is passed to hsl() and hsla(), like in CSS. They are passthrough function.

Dependents (0)

Package Sidebar

Install

npm i hsl.scss

Weekly Downloads

2

Version

1.0.1

License

WTFPL

Unpacked Size

3.78 kB

Total Files

4

Last publish

Collaborators

  • meduz