npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

colorgenn

v1.2.3

Published

Readme

colorgenn

A lightweight utility library for generating hex color codes, featuring both random color generation and AI-powered color extraction from natural language using Google's Gemini AI.

Features

  • 🎲 Random Generation - Create completely random hex color codes
  • 🤖 AI-Powered Colors - Convert natural language descriptions into matching hex codes
  • 🧩 TypeScript Support - Full TypeScript definitions included
  • ⚡ Zero Dependencies - Minimal footprint (except for optional Gemini integration)
  • 🚀 Simple API - Easy to integrate with any JavaScript/TypeScript project

Installation

# Using npm
npm install colorgenn

# Using yarn
yarn add colorgenn

# Using pnpm
pnpm add colorgenn

Usage

Generate Random Hex Colors

Generate completely random hex color codes with a single function call:

import { randomHexColor } from "colorgenn";

const color = randomHexColor();
console.log(color); // Example output: "#a1f2cc"

Get AI-Generated Colors from Natural Language

Convert natural language descriptions into relevant hex color codes using Gemini AI:

import { getColorFromPrompt } from "colorgenn";

// Async function to get a color from a description
async function generateColor() {
  const color = await getColorFromPrompt("a vibrant sunset orange with hints of red");
  console.log(color); // Example output: "#ff7842"
}

generateColor();

Gemini AI Integration

To use the natural language color generation feature, you'll need a Gemini API key:

  1. Create an account at Google AI Studio
  2. Generate an API key
  3. Configure your environment:
# .env file
VITE_API_KEY=your_gemini_api_key_here

For other frameworks, use the appropriate environment variable format (e.g., REACT_APP_API_KEY for Create React App).

React Integration Example

Here's how to integrate with a React application:

import { useState, useEffect } from "react";
import { getColorFromPrompt } from "colorgenn";

function ColoredBackground() {
  const [color, setColor] = useState("#ffffff");
  const [isLoading, setIsLoading] = useState(true);

  useEffect(() => {
    async function fetchColor() {
      setIsLoading(true);
      try {
        const newColor = await getColorFromPrompt("a calming blue for a meditation app");
        setColor(newColor);
      } catch (error) {
        console.error("Failed to fetch color:", error);
      } finally {
        setIsLoading(false);
      }
    }
    
    fetchColor();
  }, []);

  return (
    <div 
      className="w-full min-h-screen flex items-center justify-center text-white text-2xl transition-colors duration-500"
      style={{ backgroundColor: color }}
    >
      {isLoading ? "Loading color..." : `Current color: ${color}`}
    </div>
  );
}

export default ColoredBackground;

API Reference

randomHexColor()

Generates a random hex color code.

  • Returns: string - A hex color code (e.g., "#a1f2cc")

getColorFromPrompt(prompt: string)

Generates a hex color code from a natural language description using Gemini AI.

  • Parameters:
    • prompt (string): A natural language description of the color
  • Returns: Promise<string> - A hex color code matching the description
  • Requires: Valid Gemini API key set in environment variables

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments


Made with ❤️ by Jeet