Skip to content

boracomet/comet-color-picker

Repository files navigation

🎨 Comet Color Picker

MIT License Live Demo

A beautiful, animated color picker component with HSV/Hex support, custom presets, and dark mode. Copy-paste ready for React, Next.js, Vite, Webpack, Remix, and Astro.

🌐 Live Demo

https://boracomet.github.io/comet-color-picker/

Presets Tab Custom Color Picker

✨ Features

  • 🎨 HSV & Hex Color Modes - Precise color selection with visual HSV picker
  • 🌈 Custom Presets - Quick access to common colors with customizable presets
  • πŸŒ™ Dark Mode - Built-in light and dark themes
  • 🎬 Smooth Animations - Powered by Framer Motion
  • πŸ“± Touch Support - Works great on mobile devices
  • πŸ”§ TypeScript - Full type safety included
  • 🎯 Portal Rendering - No z-index issues, renders in document body

⚠️ Important

This is NOT an npm package. You need to copy the component files directly into your project.

πŸ“¦ Installation

Step 1: Clone or Download

git clone https://github.com/boracomet/comet-color-picker.git

Step 2: Copy Component Files

Copy the following folders to your project:

src/
β”œβ”€β”€ components/
β”‚   β”œβ”€β”€ color-picker/
β”‚   β”‚   β”œβ”€β”€ ColorPicker.tsx    # Main component
β”‚   β”‚   └── index.ts           # Export
β”‚   └── ui/
β”‚       β”œβ”€β”€ button.tsx         # Button component
β”‚       └── input.tsx          # Input component
└── lib/
    └── utils.ts               # cn() utility function
# Example for Next.js / Vite / React projects:
cp -r comet-color-picker/src/components/color-picker ./src/components/
cp -r comet-color-picker/src/components/ui ./src/components/
cp -r comet-color-picker/src/lib ./src/

Step 3: Install Dependencies

npm install framer-motion chroma-js lucide-react clsx tailwind-merge class-variance-authority
npm install -D @types/chroma-js

πŸš€ Quick Start

React / Vite / Webpack

import { useState } from 'react';
import { ColorPicker } from './components/color-picker';

function App() {
  const [color, setColor] = useState('#3b82f6');
  
  return (
    <ColorPicker 
      color={color} 
      onChange={setColor}
      theme="dark"
    />
  );
}

Next.js (App Router)

'use client';

import { useState } from 'react';
import { ColorPicker } from '@/components/color-picker';

export default function Page() {
  const [color, setColor] = useState('#3b82f6');
  
  return (
    <ColorPicker 
      color={color} 
      onChange={setColor}
      theme="dark"
    />
  );
}

Remix

import { useState } from 'react';
import { ColorPicker } from '~/components/color-picker';

export default function Index() {
  const [color, setColor] = useState('#3b82f6');
  
  return (
    <div className="p-8">
      <ColorPicker 
        color={color} 
        onChange={setColor}
        theme="dark"
      />
    </div>
  );
}

Astro

// src/components/ColorPickerWrapper.tsx
import { useState } from 'react';
import { ColorPicker } from './color-picker';

export default function ColorPickerWrapper() {
  const [color, setColor] = useState('#3b82f6');
  return <ColorPicker color={color} onChange={setColor} theme="dark" />;
}
---
// src/pages/index.astro
import ColorPickerWrapper from '../components/ColorPickerWrapper';
---

<html>
  <body>
    <ColorPickerWrapper client:load />
  </body>
</html>

πŸ“– Props

Prop Type Default Description
color string β€” Current color value (hex format)
onChange (color: string) => void β€” Callback when color changes
theme 'light' | 'dark' 'light' Theme mode
presetColors string[] Default colors Custom preset colors array
defaultColor string '#3b82f6' Default color for reset button
disabled boolean false Disable the picker

🎨 Custom Presets

<ColorPicker 
  color={color} 
  onChange={setColor}
  presetColors={[
    '#10b981', '#059669', '#047857',
    '#22c55e', '#16a34a', '#15803d',
  ]}
  defaultColor="#10b981"
/>

🎨 Default Preset Colors

const DEFAULT_PRESET_COLORS = [
  '#ffffff', '#f4f4f5', '#e4e4e7', '#d4d4d8', '#a1a1aa', 
  '#71717a', '#3f3f46', '#18181b', '#000000',
  '#ef4444', '#f97316', '#f59e0b', '#eab308', '#84cc16', 
  '#22c55e', '#10b981', '#06b6d4', '#3b82f6', '#6366f1', '#a855f7',
];

πŸ› οΈ Dependencies

  • framer-motion - Animations
  • chroma-js - Color manipulation
  • lucide-react - Icons
  • clsx & tailwind-merge - Class utilities
  • class-variance-authority - Button variants

πŸ”§ Development

# Clone the repo
git clone https://github.com/boracomet/comet-color-picker.git

# Install dependencies
cd comet-color-picker
npm install

# Run development server
npm run dev

# Open http://localhost:3000

🀝 Contributing

Contributions are welcome! Feel free to submit issues and pull requests.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“„ License

MIT License Β© 2026 Bora Turkoglu

See LICENSE for more information.


🌐 Live Demo β€’ ⭐ Star on GitHub

Built with ❀️ using React, Next.js, TailwindCSS & Framer Motion

About

A modern color picker designed for web developers.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors