# bg-color-variant()

The mixin contains the **two** CSS classes, the CSS class of the name prefixed with `bg-`, and prefixed `#{$prefix}-bg-` with the given [`$name`](#usdname-primary) that includes the [`background`](https://developer.mozilla.org/en-US/docs/Web/CSS/background) color of the given [`$color`](#usdcolor-primary-color) CSS variable name, and `color` style equal to `light-color` depending on whether the given SCSS variable [`$hex-color`](#usdhex-color-usdprimary-color) lightness is below **`60`**.

By default, [`$prefix`](#usdprefix-usdvar-prefix) is equal to the globally customizable [`$var-prefix`](/variables/css-variable-name.md#usdvar-prefix).

{% hint style="success" %}
The mixin contains additional CSS class that includes in its name global prefix `$var-prefix`.&#x20;

`.#{$prefix}-bg-#{$name}`
{% endhint %}

{% code title="src/mixins/color/\_bg-color-variant.mixin.scss" %}

```scss
@mixin bg-color-variant($name, $color, $hex-color, $prefix: $var-prefix) {
  .bg-#{$name},
  .#{$prefix}-bg-#{$name} {
    @include background($color, $important: !important);
    @if (lightness($hex-color) < 60) {
      @include color('light');
    }
  }
}
```

{% endcode %}

{% embed url="<https://github.com/angular-package/spectre.css/blob/1.0.x/src/mixins/_color.scss>" %}

### Parameters

#### `$name: 'primary'`

The suffix for the name of the contained CSS class `.bg`, by default it is set to `primary`.

#### `$color: 'primary-color'`

A color name that exists as a CSS variable of a string type is passed to the [`color()`](/function/color/color.md) function to set the [background](https://developer.mozilla.org/en-US/docs/Web/CSS/background) color.

#### `$hex-color: $primary-color`

The hex color of the given [`$color`](#usdcolor-primary-color) CSS variable name is used to add `color` style equal to `light-color` depending on whether its lightness is below **`60`**. By default, it is set to the [`$primary-color`](/variables/colors/color-code.md#usdprimary-color).

#### `$prefix: $var-prefix`

The parameter is to customize the prefix of the second contained CSS class name. By default, it is set to the global SASS variable [`$var-prefix`](/variables/css-variable-name.md#usdvar-prefix).

## Example usage

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


```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://spectrecss.angular-package.dev/mixin/color/bg-color-variant.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
