Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/brandonhimpfen/is-hex-color-code
A simple npm package to validate hexadecimal color codes.
https://github.com/brandonhimpfen/is-hex-color-code
code color colour hex hex-code hex-codes hex-color hex-colors hexidecimal
Last synced: 3 days ago
JSON representation
A simple npm package to validate hexadecimal color codes.
- Host: GitHub
- URL: https://github.com/brandonhimpfen/is-hex-color-code
- Owner: brandonhimpfen
- License: mit
- Created: 2023-06-20T22:52:22.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-06-20T23:09:51.000Z (over 1 year ago)
- Last Synced: 2025-01-18T13:13:50.189Z (12 days ago)
- Topics: code, color, colour, hex, hex-code, hex-codes, hex-color, hex-colors, hexidecimal
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/is-hex-color-code
- Size: 2.93 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# is-hex-color-code
[![npm version](https://img.shields.io/npm/v/is-hex-color-code.svg)](https://www.npmjs.com/package/is-hex-color-code)
A simple npm package to validate hexadecimal color codes.
## Installation
You can install the package using npm:
```
npm install is-hex-color-code
```## Usage
Import the `isHex` function into your project and use it to check if a value is a valid hexadecimal color code.
```
const isHex = require('is-hex-color-code');console.log(isHex('#FFFFFF')); // Output: true
console.log(isHex('#123abc')); // Output: true
console.log(isHex('invalid')); // Output: false
console.log(isHex('#HHJJZZ')); // Output: false
console.log(isHex('#ACBD')); // Output: false
```The `isHex` function accepts a color value as input and returns `true` if it is a valid hexadecimal color code (with or without the `#` prefix), and `false` otherwise.