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
  1. Mixin
  2. Label

label-variant()

Previouslabel-base()Nextlabel-class-variant()

Last updated 2 years ago

The mixin contains the and style of the values given respectively by and CSS variable name. Both parameters can be passed as a two-index where the second item in the list refers to the lightness, and parameter can be passed using the three-index where the third item is a label background alpha.

For example $color: ('primary', -10%) when font color primary should be darker by 10%, and $bg-color: ('primary-dark', 10%) when label background color is primary-dark lighter by 10%.

src/mixins/_label.scss
@mixin label-variant(
  $color: 'light-color',
  $bg-color: 'primary-color',
  $color-lightness: 0%,
  $bg-lightness: 0%
) {
  $alpha: 1;
  @if list.length($color) > 1 {
    $color-lightness: list.nth($color, 2);
    $color: list.nth($color, 1);
  }

  @if list.length($bg-color) > 1 {
    @if list.length($bg-color) == 3 {
      $alpha: list.nth($bg-color, 3);
    }

    $bg-lightness: list.nth($bg-color, 2);
    $bg-color: list.nth($bg-color, 1);
  }

  background: color($bg-color, $lightness: $bg-lightness, $alpha: $alpha);
  color: color($color, $lightness: $color-lightness);
}

Parameters

$color: 'light-color'

$bg-color: 'primary-color'

$color-lightness: 0%

$bg-lightness: 0%

Example usage

// Get mixin.
@use 'node_modules/@angular-package/spectre.css/src/mixins/label' as *;

// Accent label lighter by 10% with font `light-color` darker by 10%.
.label-accent {
  @include label-variant(
    $color: ('light-color', -10%),
    $bg-color: ('accent-color', 10%)
  );

  // OR

  @include label-variant(
    $color: 'light-color',
    $bg-color: 'accent-color',
    $color-lightness: -10%,
    $bg-lightness: 10%
  );
}

A color name that exists as a CSS variable of a string or two-index type is passed to the function to set the foreground color value of a label's text. The first item of the two-index list refers to the CSS variable color name, and the second refers to its lightness.

A color name that exists as a CSS variable of a string or three-index type is passed to the function to set the background color of the label. The first item of the three-index refers to the CSS variable color name, the second refers to its lightness, and the third refers to the alpha.

Optional alternative lightness attribute of the given parameter.

Optional alternative lightness attribute of the given parameter.

list
color()
list
color()
list
color
background
list
list
$color
$bg-color
$bg-color
$color
$bg-color
Logospectre.css/_label.scss at master · angular-package/spectre.cssGitHub