> For the complete documentation index, see [llms.txt](https://spectrecss.angular-package.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://spectrecss.angular-package.dev/variables/colors/using-css-variable-color.md).

# Using CSS variable color

To easily use color defined in **four** CSS variables with the help comes [`color()`](/function/color/color.md) function, which takes **six** parameters: `$name`, `$hue`, `$lightness`, `$saturation`, `$alpha`, and `$prefix`, and returns color in [**hsla()**](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/hsla) form.

There is only `$name` parameter **required**, and the `$hue` `$lightness` `$saturation` default values are set to `0`, `$alpha` default value is set to `1`, and `$prefix` default value is equal to [`$var-prefix`](/variables/css-variable-name.md#usdvar-prefix). So, it's very easy to insert the color into any style and change the default value of the CSS variable color, for example `primary-color` or `primary-color-dark` can be inserted as follows.

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

.primary-color {
  background: color('primary-color');
}

.primary-color-dark {
  background: color('primary-color-dark');
}
```

With the optional parameters, it's possible to inject `primary-color` lighter or darker by **`30%`**, and it's useful, especially on mixing background with font color, and it works like [`darken()`](https://sass-lang.com/documentation/modules/color#darken) and [`lighten()`](https://sass-lang.com/documentation/modules/color#lighten), but with the ability to change the value on the fly cause of the CSS variables.

```scss
@use 'node_modules/@angular-package/spectre.css/functions' as *;

.primary-color-lighter {
  background: color('primary-color', $lightness: -30%);
  color: color('primary-color', $lightness: 30%);
}

.primary-color-darker {
  background: color('primary-color', $lightness: -30%);
}
```

There are other SASS variables besides colors, that have equivalent CSS variables and default prefix **`s`**.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://spectrecss.angular-package.dev/variables/colors/using-css-variable-color.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
