color-picker
ui-layouts-aiveilix/color-pickerFreeComponent
ui-layouts publishes no description for this item.
Install it
npx shadcn@latest add https://raw.githubusercontent.com/jutt313/AIVEILIX-old/main/for ui/apps/ui-layout/public/r/color-picker.jsonSource
1"use client";23import { Button } from "@/components/website/ui/button";4import { Input } from "@/components/website/ui/input";5import { Label } from "@/components/website/ui/label";6import {7 Popover,8 PopoverContent,9 PopoverTrigger,10} from "@/components/website/ui/popover";11import { cn } from "@/lib/utils";12import { Copy, Pipette } from "lucide-react";13import { HexColorPicker } from "react-colorful";14import { toast } from "sonner";1516interface ColorPickerProps {17 color: string18 onChange: (color: string) => void19 label: string20 isEyeDroppper?:boolean21 className?:string22}2324export function ColorPicker({25 color,26 onChange,27 label,28 isEyeDroppper = false,29 className,30}: ColorPickerProps) {31 function copyToClipboard() {32 navigator.clipboard.writeText(color);33 toast("Copied!", {34 description: `${color} copied to clipboard`,35 duration: 2000,36 });37 }3839 async function useEyeDropper() {40 if (!("EyeDropper" in window)) {41 toast.error("Not supported", {42 description: "Eyedropper is not supported in your browser",43 duration: 3000,44 });45 return;46 }4748 try {49 // @ts-expect-error - EyeDropper is not in the TypeScript DOM types yet50 const eyeDropper = new window.EyeDropper();51 const result = await eyeDropper.open();52 onChange(result.sRGBHex);53 } catch (e) {54 console.error("Error using eyedropper", e);55 }56 }5758 return (59 <div className={cn("flex items-center gap-2",className)}>60 <Label className="w-24">{label}</Label>61 <Popover>62 <PopoverTrigger asChild>63 <Button64 variant="outline"65 className="h-8 w-12 border-2 p-0"66 style={{ backgroundColor: color }}67 >68 <span className="sr-only">Pick a color</span>69 </Button>70 </PopoverTrigger>71 <PopoverContent className="w-full p-3 bg-primary-foreground">72 <HexColorPicker73 color={color}74 onChange={onChange}75 className="w-full!"76 />77 <div className="mt-2 flex w-full gap-2">78 <Input79 value={color}80 onChange={(e) => onChange(e.target.value)}81 className="h-10 w-full"82 />83 <Button84 variant="outline"85 size="icon"86 onClick={copyToClipboard}87// … truncated
Files it writes
More from ui-layouts
All 230 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| 3d-marquee3d-marquee | ui-layouts | Components | Free | no deps · 2 files | |
| accordionaccordion | ui-layouts | Components | Free | no deps | |
| align-slideralign-slider | ui-layouts | Components | Free | 6 deps · 2 files | |
| animal-imagemaskinganimal-imagemasking | ui-layouts | Components | Free | 1 dep | |
| animated-beamanimated-beam | ui-layouts | Components | Free | no deps | |
| animated-beam-bidirectionalanimated-beam-bidirectional | ui-layouts | Components | Free | no deps | |
| animated-beam-defaultanimated-beam-default | ui-layouts | Components | Free | no deps | |
| animated-beam-multiple-inputanimated-beam-multiple-input | ui-layouts | Components | Free | no deps |
