is-hex-color-code

1.0.0 • Public • Published

is-hex-color-code

npm version

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.

Readme

Keywords

Package Sidebar

Install

npm i is-hex-color-code

Weekly Downloads

2

Version

1.0.0

License

MIT

Unpacked Size

3.15 kB

Total Files

5

Last publish

Collaborators

  • brandonhimpfen