# has-color()

## 용도 <a href="#use" id="use"></a>

색 구성표에 등록된 컬러 이름이 포함되어 있는 지 확인 후 결과를 반환합니다.

{% hint style="info" %}
[환경 구성 변수 $colors](https://yamoo9.gitbook.io/scss-mixins/getting-started/configure#undefined)에 사용자가 임의로 컬러 이름에 매칭되는 값을 등록할 수 있습니다.
{% endhint %}

## 사용법 <a href="#usage" id="usage"></a>

`has-color()` 함수에 확인 할 컬러 이름을 전달합니다.

> has-color($name:**string**) → **bool**

```javascript
@debug has-color('white');  // true 반환
@debug has-color('indigo'); // false 반환
```

| 매개변수(parameter) | 유형(type) | 필수(required) | 기본 값(default) |
| :-------------: | :------: | :----------: | :-----------: |
|      $name      |  string  |      ✔︎      |               |

## 로직 <a href="#logic" id="logic"></a>

`has-color()` 유틸리티는 다음의 로직에 의해 작성되었습니다.&#x20;

```javascript
@function has-color($name) {
  @return map-has-key($colors, $name);
}
```

1. 전달 받은 컬러 이름(`$name`)이 [ $colors 구성 변수](https://yamoo9.gitbook.io/scss-mixins/getting-started/configure#undefined)에 등록된 이름인지 검사
2. 컬러 이름이 컬러 구성표에 포함된 이름인 경우, `true` 반환
3. 컬러 이름이 컬러 구성표에 포함되지 않은 이름인 경우, `false` 반환

## 참고 <a href="#reference" id="reference"></a>

유틸리티 함수 로직에 사용된 Sass 빌트인 모듈은 다음과 같습니다.

* [map-has-key()](https://sass-lang.com/documentation/modules/map#has-key)

{% hint style="info" %}
Sass의 Map 자료형(Data Type)은 JavaScript의 Object와 유사합니다.
{% endhint %}

{% embed url="<https://sass-lang.com/documentation/modules/map>" %}


---

# 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://yamoo9.gitbook.io/scss-mixins/utilities/colors/has-color.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.
