BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/ridiculous/gradient-editor

Gradient Editor

ridiculous/gradient-editor
FreeComponent

Linear / radial / conic gradient editor with draggable stops, position picker, oklch-default interpolation, and reusable color-picker stops.

Install it

npx shadcn@latest add http://ridiculous.turtlesocks.dev/r/gradient-editor.json

Source

src/components/ui/gradient-editor/gradient-editor.tsxridiculous.turtlesocks.dev/r/gradient-editor.json · first 6 KB
1"use client"
2
3import { useEffect, useMemo, useRef, useState } from "react"
4import { Button } from "@/components/ui/button"
5import { ColorPicker } from "@/components/ui/color-picker"
6import {
7 Popover,
8 PopoverContent,
9 PopoverTrigger,
10} from "@/components/ui/popover"
11import { UnitInput } from "@/components/ui/unit-input"
12import { cn } from "@/lib/utils"
13import {
14 formatGradient,
15 fromUnitString,
16 GRADIENT_TYPES,
17 INTERPOLATION_SPACES,
18 type InternalState,
19 nextStopId,
20 POLAR_SPACES,
21 parseGradient,
22 toDeg,
23 toPct,
24} from "./gradient-editor.helpers"
25import type {
26 GradientString,
27 GradientStringMap,
28 GradientType,
29 InternalStop,
30 InterpolationHueMethod,
31 InterpolationSpace,
32 PolarSpace,
33} from "./gradient-editor.types"
34
35// ---------------------------------------------------------------------------
36// Component (top of file)
37// ---------------------------------------------------------------------------
38
39export interface GradientEditorProps<
40 TType extends GradientType | undefined = undefined,
41> {
42 value: GradientString | (string & {})
43 onChange: (
44 value: TType extends GradientType
45 ? GradientStringMap[TType]
46 : GradientString,
47 ) => void
48 type?: TType
49 maxStops?: number
50 className?: string
51 "aria-label"?: string
52}
53
54export function GradientEditor<TType extends GradientType | undefined>({
55 value,
56 onChange,
57 type: typeProp,
58 maxStops = 8,
59 className,
60 "aria-label": ariaLabel = "Edit gradient",
61}: GradientEditorProps<TType>) {
62 const parsed = useMemo(() => parseGradient(value), [value])
63 if (!parsed) {
64 return (
65 <span
66 aria-hidden="true"
67 className={cn(
68 "inline-block h-5 w-12 rounded border bg-muted",
69 className,
70 )}
71 style={{ backgroundColor: value }}
72 data-slot="gradient-editor-fallback"
73 />
74 )
75 }
76 return (
77 <GradientEditorBody
78 value={value}
79 initial={parsed}
80 onChange={onChange as (next: string) => void}
81 typeProp={typeProp}
82 maxStops={maxStops}
83 className={className}
84 ariaLabel={ariaLabel}
85 />
86 )
87}
88
89interface GradientEditorBodyProps {
90 value: string
91 initial: InternalState
92 onChange: (next: string) => void
93 typeProp: GradientType | undefined
94 maxStops: number
95 className: string | undefined
96 ariaLabel: string
97}
98
99function GradientEditorBody({
100 value,
101 initial,
102 onChange,
103 typeProp,
104 maxStops,
105 className,
106 ariaLabel,
107}: GradientEditorBodyProps) {
108// … truncated

What it pulls in

Other registry items

  • button
  • popover
  • color-picker
  • unit-input

Files it writes

  • src/components/ui/gradient-editor/index.ts
  • src/components/ui/gradient-editor/gradient-editor.tsx
  • src/components/ui/gradient-editor/gradient-editor.helpers.ts
  • src/components/ui/gradient-editor/gradient-editor.types.ts

Facts

Registry
ridiculous
Type
registry:ui
Access
Free
Files written
4
Licence
MIT
First indexed
2026-08-03
Last confirmed
yesterday

Go to the source

ridiculous.turtlesocks.dev TurtIeSocks/ridiculous on GitHub Raw registry item This item as JSON

More from ridiculous

All 22 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
All ridiculous componentsallridiculousComponentsFreeno deps
Anchor Position Editoranchor-position-editorridiculousComponentsFreeno deps · 9 files
Background Editorbackground-editorridiculousComponentsFreeno deps · 9 files
Box Shadow Editorbox-shadow-editorridiculousComponentsFreeno deps · 7 files
Calc Editorcalc-editorridiculousComponentsFreeno deps · 4 files
Clip Path Editorclip-path-editorridiculousComponentsFreeno deps · 20 files
Color Functioncolor-functionridiculousComponentsFreeno deps · 10 files
Color Pickercolor-pickerridiculousComponentsFreeno deps · 11 files
BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex