BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/ridiculous/background-editor

Background Editor

ridiculous/background-editor
FreeComponent

Ridiculously typed editor for the CSS background shorthand. An index-aware fold permits a <color> token only on the final layer, so a color in any earlier layer is a compile error. A reorderable layer stack embeds the real gradient + color pickers over a live composite preview.

Install it

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

Source

src/components/ui/background-editor/background-editor.tsxridiculous.turtlesocks.dev/r/background-editor.json · first 6 KB
1"use client"
2
3import { useEffect, useRef, useState } from "react"
4import { Button } from "@/components/ui/button"
5import {
6 Popover,
7 PopoverContent,
8 PopoverTrigger,
9} from "@/components/ui/popover"
10import { cn } from "@/lib/utils"
11import {
12 defaultBackground,
13 formatBackground,
14 parseBackground,
15} from "./background-editor.helpers"
16import type { BackgroundString, BgLayer } from "./background-editor.types"
17import { BackgroundPreview } from "./background-preview"
18import { LayerStack } from "./layer-stack"
19
20// Re-export the public sub-components + their prop types so consumers (and the
21// barrel) can import them from `./background-editor`.
22export type { BackgroundPreviewProps } from "./background-preview"
23export { BackgroundPreview } from "./background-preview"
24export type { LayerCardProps } from "./layer-card"
25export { LayerCard } from "./layer-card"
26export type { LayerStackProps } from "./layer-stack"
27export { LayerStack } from "./layer-stack"
28export type { MiniSelectProps } from "./mini-select"
29export { MiniSelect } from "./mini-select"
30export type { PositionPadProps } from "./position-pad"
31export { PositionPad } from "./position-pad"
32
33// ---------------------------------------------------------------------------
34// Props
35// ---------------------------------------------------------------------------
36
37export interface BackgroundEditorPanelProps {
38 value: BackgroundString | (string & {})
39 onChange: (value: BackgroundString) => void
40 className?: string
41 "aria-label"?: string
42}
43
44export interface BackgroundEditorProps extends BackgroundEditorPanelProps {}
45
46// ---------------------------------------------------------------------------
47// color re-homing — the index-aware invariant, kept true under reorder
48// ---------------------------------------------------------------------------
49
50/**
51 * Keep the `<color>` on the FINAL layer no matter how the stack is reordered.
52 * A reorder swaps whole layer objects, so a color that was on the last layer
53 * would otherwise travel with its object into a non-final slot and be dropped
54 * by `formatBackground` (which only emits a color on the last layer). This
55 * collects any color found anywhere in the stack and re-homes it onto the last
56 * layer, stripping it from every other — so the invariant survives a reorder.
57 */
58function migrateColorToFinal(layers: BgLayer[]): BgLayer[] {
59 if (layers.length === 0) return layers
60 // The last non-empty color wins (mirrors CSS: only the final layer's color
61// … truncated

What it pulls in

Other registry items

  • ridiculous-type-kit
  • color-picker
  • gradient-editor
  • unit-input
  • button
  • popover
  • input

Files it writes

  • src/components/ui/background-editor/index.ts
  • src/components/ui/background-editor/background-editor.tsx
  • src/components/ui/background-editor/background-editor.types.ts
  • src/components/ui/background-editor/background-editor.helpers.ts
  • src/components/ui/background-editor/layer-stack.tsx
  • src/components/ui/background-editor/layer-card.tsx
  • src/components/ui/background-editor/position-pad.tsx
  • src/components/ui/background-editor/background-preview.tsx
  • src/components/ui/background-editor/mini-select.tsx

Facts

Registry
ridiculous
Type
registry:ui
Access
Free
Files written
9
Licence
MIT
In the index
at or before 2026-08-08
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
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
Easing Pickereasing-pickerridiculousComponentsFreeno deps · 17 files

Also from Kynth Studios

Built for the same person as BlockDex

SkillWorks

Claude Code skills and plugins, scored

skillworks.kynth.studio

RuleStack

AGENTS.md gallery and agent-config comparison

rulestack.kynth.studio

KitGrade

SaaS starter kits, scored from measured facts

kitgrade.kynth.studio

The studio list

One product, taken apart, once a month

Kynth Studios pulls one shipped product open every month — what it does, what it cost to build, what the pipeline behind it looks like, and what the numbers did. One email a month, nothing in between.

Double opt-in — we send one confirmation link and nothing else until you click it.

BlockDex

Built by

Kynth Studios

the studio behind SkillWorks, RuleStack and KitGrade

part of Toolproof, the measurement layer for AI agent tooling

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

© 2026 BlockDex. A Kynth Studios product. Changelog

BlockDex

The studio list

One product, taken apart, once a month

Kynth Studios pulls one shipped product open every month — what it does, what it cost to build, what the pipeline behind it looks like, and what the numbers did. One email a month, nothing in between.

Double opt-in — we send one confirmation link and nothing else until you click it.

BlockDex

Built by

Kynth Studios

the studio behind SkillWorks, RuleStack and KitGrade

part of Toolproof, the measurement layer for AI agent tooling

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

© 2026 BlockDex. A Kynth Studios product. Changelog

BlockDex

The studio list

One product, taken apart, once a month

Kynth Studios pulls one shipped product open every month — what it does, what it cost to build, what the pipeline behind it looks like, and what the numbers did. One email a month, nothing in between.

Double opt-in — we send one confirmation link and nothing else until you click it.

BlockDex

Built by

Kynth Studios

the studio behind SkillWorks, RuleStack and KitGrade

part of Toolproof, the measurement layer for AI agent tooling

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

© 2026 BlockDex. A Kynth Studios product. Changelog

BlockDex