Spectre.css
  • Introduction
  • ❤ Benefits
  • General concepts
  • Getting started
    • Skeleton
    • Installation
      • npm
    • Usage
  • Variables
    • Color scheme
    • CSS variable name
    • Using CSS variables
    • Colors
      • Settable SCSS
      • Based on settable SCSS
      • CSS variable color
      • Using CSS variable color
      • Color code
    • Other
  • CSS Color Classes
    • Background colors
    • Label colors
    • ⚠ Text colors
    • ⚠ Toast colors
  • Function
    • Color
      • alpha-var()
      • color()
      • color-name()
      • hsla-color()
      • hue-var()
      • lightness-level-var()
      • lightness-var()
      • saturation-var()
    • Var
      • css-var()
      • get-var()
      • size-var()
      • unit-var()
      • var-adjust()
      • var-name()
      • var-negative()
      • var-unit()
    • get-border()
    • get-from-list()
    • important()
    • map-get-default()
    • strip-unit()
    • typeof()
  • Mixin
    • Border
      • border()
      • border-hover()
      • border-variant()
    • Color
      • background()
      • background-color()
      • bg-color-variant()
      • color-active()
      • color-focus()
      • color-hover()
      • color-picker()
      • color-visited()
      • set-color()
      • set-var-alpha()
      • text-color-variant()
    • Label
      • label-base()
      • label-variant()
      • label-class-variant()
    • Margin
      • margin-size-variants()
      • margin-variant()
    • Padding
      • padding-size-variants()
      • padding-variant()
    • Text
      • text-ellipsis()
    • Toast
      • toast-variant()
      • ⚠ toast-class-variant()
    • Var
      • set-var()
      • set-vars()
      • ⚠ define-color()
      • ⚠ define-color-based-on()
    • avatar-base()
    • box-shadow-side()
    • button-variant()
    • clearfix()
    • control-shadow()
    • disabled()
    • hide-scrollbar()
    • property()
    • shadow-variant()
    • transition()
    • z-index()
  • Change log
    • Keep a changelog
    • CHANGELOG.md
  • GIT
    • Commit
    • Semantic Versioning
  • License
    • MIT
  • Social
    • Gettr
    • Twitter
    • YouTube
  • Contact
    • ⋯ Chat
    • @ Email
    • ✆ Phone
  • Donate
    • ฿ Cryptocurrency
    • $ Fiat
Powered by GitBook
On this page
  • Parameters
  • Example usage
  • Source
  1. Function
  2. Color

color()

Previousalpha-var()Nextcolor-name()

Last updated 2 years ago

The function color() returns the color from the four CSS variables of the given . The parameter can be passed as two-index list, where the second item is the , or can be passed as three-index list, where the third item is the .

The function color() returns the hsla() color from a CSS variables of the given $name.

src/functions/_color.function.scss
@function color(
  $name,
  $hue: 0deg,
  $saturation: 0%,
  $lightness: 0%,
  $alpha: 0,
  $prefix: $var-prefix
) {
  @return hsla-color(
    $name,
    $hue,
    $saturation,
    $lightness,
    $alpha,
    $prefix
  );
}

Parameters

$name

$hue: 0deg

Hue is a degree on the color wheel from 0 to 360. 0 is red, 120 is green, and 240 is blue. By default, it's set to 0deg.

$saturation: 0%

Saturation is a percentage value, 0% means a shade of gray, and 100% is the full color. By default, it's set to 0%.

$lightness: 0%

Lightness is also a percentage, 0% is black, 50% is neither light or dark, 100% is white

$alpha: 1

The alpha parameter is a number between 0.0 (fully transparent) and 1.0 (not transparent at all)

$prefix: $var-prefix

Example usage

@use 'node_modules/@angular-package/spectre.css/src/functions/color' as *;

.example-bg {
  background-color: color('secondary-color');
}

Source

Source of definitions hex, saturation, lightness, and alpha.

A color name that exists as a CSS variable of a string or two/three-index type is passed to the function to set the CSS variable's color name.

If name is passed as two-index list the first item refers to the CSS variable color name, the second refers to , and the third of the three-index list item refers to its .

The name's prefix of the four CSS variables, by default it's set to .

list
color()
$lightness
$alpha
hsla()
$name
$name
$lightness
$alpha
Logospectre.css/_color.scss at master · angular-package/spectre.cssGitHub
LogoCSS HSL Colors
$var-prefix