Aurora ColorPicker
aurora-dinglebear-ai/aurora-color-pickerFreeComponent
Aurora ColorPicker — Claude Design parity.
Install it
npx shadcn@latest add https://aurora.dinglebear.ai/r/aurora-color-picker.jsonSource
1"use client"23import * as React from "react"4import { cn } from "@/lib/utils"56// --- color math -------------------------------------------------------------78interface Hsv {9 h: number // 0..36010 s: number // 0..111 v: number // 0..112}1314function clamp(n: number, min: number, max: number): number {15 return Math.min(max, Math.max(min, n))16}1718function hexToRgb(hex: string): { r: number; g: number; b: number } | null {19 const m = /^#?([0-9a-f]{6})$/i.exec(hex.trim())20 if (!m) return null21 const int = parseInt(m[1], 16)22 return { r: (int >> 16) & 255, g: (int >> 8) & 255, b: int & 255 }23}2425function rgbToHex(r: number, g: number, b: number): string {26 const to = (n: number) => clamp(Math.round(n), 0, 255).toString(16).padStart(2, "0")27 return `#${to(r)}${to(g)}${to(b)}`28}2930function rgbToHsv(r: number, g: number, b: number): Hsv {31 const rr = r / 25532 const gg = g / 25533 const bb = b / 25534 const max = Math.max(rr, gg, bb)35 const min = Math.min(rr, gg, bb)36 const d = max - min37 let h = 038 if (d !== 0) {39 if (max === rr) h = ((gg - bb) / d) % 640 else if (max === gg) h = (bb - rr) / d + 241 else h = (rr - gg) / d + 442 h *= 6043 if (h < 0) h += 36044 }45 const s = max === 0 ? 0 : d / max46 return { h, s, v: max }47}4849function hsvToRgb({ h, s, v }: Hsv): { r: number; g: number; b: number } {50 const c = v * s51 const x = c * (1 - Math.abs(((h / 60) % 2) - 1))52 const m = v - c53 let r = 054 let g = 055 let b = 056 if (h < 60) [r, g, b] = [c, x, 0]57 else if (h < 120) [r, g, b] = [x, c, 0]58 else if (h < 180) [r, g, b] = [0, c, x]59 else if (h < 240) [r, g, b] = [0, x, c]60 else if (h < 300) [r, g, b] = [x, 0, c]61 else [r, g, b] = [c, 0, x]62 return { r: (r + m) * 255, g: (g + m) * 255, b: (b + m) * 255 }63}6465function hexToHsv(hex: string): Hsv | null {66 const rgb = hexToRgb(hex)67 if (!rgb) return null68 return rgbToHsv(rgb.r, rgb.g, rgb.b)69}7071function hsvToHex(hsv: Hsv): string {72 const { r, g, b } = hsvToRgb(hsv)73 return rgbToHex(r, g, b)74}7576// Pure-hue hex (full saturation + value) for the saturation/value plane bg.77function hueHex(h: number): string {78 return hsvToHex({ h, s: 1, v: 1 })79}8081// Styles: registry/aurora/styles/aurora-components.css (@layer aurora-components).8283// --- component --------------------------------------------------------------8485export interface ColorPickerProps86 extends Omit<React.HTMLAttributes<HTMLDivElement>, "onChange" | "defaultValue"> {87 /** Caption rendered above the picker (uppercased). */88// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from aurora
All 176 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Aurora Accordionaurora-accordion | aurora | Components | Free | 2 deps | |
| Aurora Alert Dialogaurora-alert-dialog | aurora | Components | Free | 2 deps | |
| Aurora Aspect Ratioaurora-aspect-ratio | aurora | Components | Free | no deps | |
| Aurora Avataraurora-avatar | aurora | Components | Free | 1 dep | |
| Aurora Badgeaurora-badge | aurora | Components | Free | 2 deps | |
| Aurora Banneraurora-banner | aurora | Components | Free | 1 dep | |
| Aurora Breadcrumbaurora-breadcrumb | aurora | Components | Free | 2 deps | |
| Aurora Buttonaurora-button | aurora | Components | Free | 2 deps |
