# hexColor

> 3, 4, 6, or 8-digit hex colour with a leading `#`. Case-insensitive. Empty values pass.

Source: https://ngwr.dev/reference/validators/hex-color  
Kind: Validator

## Live demo

## Usage

```angular-ts
import { FormControl } from '@angular/forms';
import { WrValidators } from 'ngwr/validators';

const colour = new FormControl('', [WrValidators.hexColor]);

colour.setValue('#1a2b3c');  // → valid
colour.setValue('#xyz');     // → { hexColor: true }
```

## Why ngwr provides this

No built-in validates colour strings. This accepts the 3/4/6/8-digit hex forms (`#abc`, `#1a2b3c4d`) — handy for free-text colour fields next to [wr-color-picker](https://ngwr.dev/reference/components/color-picker).

## API

| Name | Description | Type | Default |
| --- | --- | --- | --- |
| `signature` | Static — drop into a `validators` array. | `ValidatorFn` | `—` |
| `accepted shapes` | `#abc`, `#abcd`, `#a1b2c3`, `#a1b2c3d4` (case-insensitive). Hash required. | `string` | `—` |
| `error key` | On failure: `{ hexColor: true }`. Empty value passes. | `{ hexColor: true }` | `—` |

## See also

- [wr-color-picker](https://ngwr.dev/reference/components/color-picker) — Emits the hex strings this rule accepts.
- [wr-input](https://ngwr.dev/reference/components/input) — For free-typed color values.
