CustomPicker.js

@brightdotdev/color-picker - CustomPickers.js

A lightweight, framework-agnostic color picker library built with TypeScript. Supports HSL, RGB, and CMYK color spaces with automatic CSS injection and 20+ CSS property targeting.

πŸ“¦ npm Package

npm install @brightdotdev/color-picker

πŸš€ Live Demo

Check out the live demo to see all features in action:
Live Demo Page

✨ Features

🏁 Quick Start

Installation

npm install @brightdotdev/color-picker

Basic Usage

import { COLORPICKERCLASS } from '@brightdotdev/color-picker';

const container = document.getElementById('color-picker-container');
const targetElement = document.getElementById('my-element');

const picker = new COLORPICKERCLASS({
  colorPickerContainer: container,
  colorPickerProps: {
    targetElementProps: {
      targetElement: targetElement,
      targetStylePorperty: 'background' // or any CSS color property
    }
  }
});

// Set initial color
picker.setExternalColor({ r: 255, g: 0, b: 0 });

🎨 Supported CSS Properties

Your color picker can target these CSS properties:

Text & Background

Borders & Outlines

UI & Forms

SVG

Shadows & Effects

Selection & Scrollbars

πŸ“– Documentation

Universal Picker (All Color Spaces)

import { COLORPICKERCLASS } from '@brightdotdev/color-picker';

const picker = new COLORPICKERCLASS({
  colorPickerContainer: document.getElementById('picker-container'),
  colorPickerProps: {
    targetElementProps: {
      targetElement: document.getElementById('target-element'),
      targetStylePorperty: 'border-color'
    }
  }
});

// Set initial color
picker.setExternalColor({ h: 240, s: 100, l: 50 });

// Cleanup when done
picker.dispose();

Individual Color Pickers

import { HslObject, RgbObject, CmykObject } from '@brightdotdev/color-picker';

// HSL Picker
const hslPicker = new HslObject({
  colorPickerContainer: container,
  targetElementProps: {
    targetElement: targetElement,
    targetStylePorperty: 'color'
  }
});

// Get current color
const currentColor = hslPicker.getCurrentColor();

// Cleanup
hslPicker.destroyPicker();

React Usage

import React, { useRef, useEffect } from 'react';
import { COLORPICKERCLASS } from '@brightdotdev/color-picker';

function ColorPicker() {
  const containerRef = useRef();

  useEffect(() => {
    const picker = new COLORPICKERCLASS({
      colorPickerContainer: containerRef.current,
      colorPickerProps: {
        targetElementProps: {
          targetElement: document.getElementById('preview'),
          targetStylePorperty: 'background'
        }
      }
    });

    return () => picker.dispose();
  }, []);

  return <div ref={containerRef} />;
}

πŸ”§ API Reference

Color Types

interface RGB { r: number; g: number; b: number; }        // 0-255
interface HSL { h: number; s: number; l: number; }        // 0-360, 0-100, 0-100
interface CMYK { c: number; m: number; y: number; k: number; } // 0-100

type AnyColor = RGB | HSL | CMYK;

Methods

🌐 Browser Support

Note: EyeDropper API requires Chrome 95+ or Edge 95+

🀝 Contributing & Feedback

🎯 We Welcome Contributions!

This is a 100% open source project and we actively encourage community participation! Here’s how you can help:

πŸ› Report Bugs

Found an issue? Please let us know!

πŸ’‘ Suggest Features

Have an idea to make this better?

πŸ› οΈ Code Contributions

Want to contribute code? Fantastic!

  1. 🍴 Fork the repository
  2. 🌿 Create a feature branch (git checkout -b feature/your-feuture)
  3. πŸ’Ύ Commit your changes (git commit -m 'Add amazing feature')
  4. πŸ“€ Push to the branch (git push origin feature/your-feuture)
  5. πŸ”€ Open a Pull Request

πŸ“‹ Good First Issues

New to open source? Look for issues tagged good-first-issue to get started!

πŸ§ͺ Testing Help

Help us test across different:

πŸ“š Documentation Improvements

Found a typo? Need better examples? Documentation contributions are especially welcome!

πŸ† Contribution Guidelines

We follow a friendly, inclusive, and welcoming environment. Please:

πŸ“¬ Get in Touch

πŸ“ License

MIT License - see LICENSE file for details. This means you can use, modify, and distribute this software freely!

⭐ Love this project?

πŸ“¦ npm Package: @brightdotdev/color-picker

🌐 Live Demo: Check out the demo to see all features in action!


This project is maintained with by [Brightdotdev Bright ](https://github.com/brightdotdev) (for now)