Filter Builder
ridiculous/filter-builderFreeComponent
Ridiculously typed CSS filter / backdrop-filter editor — a space-separated function list with compile-time per-function arity and dimension typing, plus a drop-shadow color validated against the color-picker ColorLiteral. Ships a tolerant runtime parser and a live preview with a filter ↔ backdrop-filter toggle.
Install it
npx shadcn@latest add http://ridiculous.turtlesocks.dev/r/filter-builder.jsonSource
1"use client"23import { 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 type { FilterMode } from "./filter-builder.constants"12import {13 defaultItem,14 formatFilter,15 parseFilter,16} from "./filter-builder.helpers"17import type {18 FilterFunctionName,19 FilterItem,20 FilterString,21} from "./filter-builder.types"22import { FilterPreview } from "./filter-preview"23import { FilterFunctionRow, FunctionOptions } from "./filter-row"2425// Re-export the extracted sub-components + their prop types so the public26// entry surface (and existing deep imports) is unchanged by the file split.27export type { FilterPreviewProps } from "./filter-preview"28export { FilterPreview } from "./filter-preview"29export type {30 FilterArgEditorProps,31 FilterFunctionRowProps,32} from "./filter-row"33export { FilterArgEditor, FilterFunctionRow } from "./filter-row"3435// ---------------------------------------------------------------------------36// Shared props37// ---------------------------------------------------------------------------3839export interface FilterBuilderPanelProps {40 value: FilterString | (string & {})41 onChange: (value: FilterString) => void42 /**43 * Which CSS property the live preview targets. Both `filter` and44 * `backdrop-filter` share the identical function-list grammar, so this does45 * not change validation or narrow the `onChange` output — it only drives the46 * preview render target + labels. Defaults to `"filter"`.47 */48 mode?: FilterMode49 className?: string50 "aria-label"?: string51}5253export interface FilterBuilderProps extends FilterBuilderPanelProps {}5455// ---------------------------------------------------------------------------56// FilterBuilder — popover-wrapped57// ---------------------------------------------------------------------------5859export function FilterBuilder(props: FilterBuilderProps) {60 const {61 value,62 className,63 "aria-label": ariaLabel = "Edit a CSS filter",64 } = props65 const items = parseFilter(String(value)) ?? []6667 return (68 <Popover>69 <PopoverTrigger asChild>70 <Button71 variant="outline"72 className={cn("h-9 gap-2 px-3 font-mono", className)}73 aria-label={ariaLabel}74 >75 <span aria-hidden="true" className="text-foreground/60">76 ✦77 </span>78// … truncated
What it pulls in
Other registry items
Files it writes
More from ridiculous
All 22 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| All ridiculous componentsall | ridiculous | Components | Free | no deps | |
| Anchor Position Editoranchor-position-editor | ridiculous | Components | Free | no deps · 9 files | |
| Background Editorbackground-editor | ridiculous | Components | Free | no deps · 9 files | |
| Box Shadow Editorbox-shadow-editor | ridiculous | Components | Free | no deps · 7 files | |
| Calc Editorcalc-editor | ridiculous | Components | Free | no deps · 4 files | |
| Clip Path Editorclip-path-editor | ridiculous | Components | Free | no deps · 20 files | |
| Color Functioncolor-function | ridiculous | Components | Free | no deps · 10 files | |
| Color Pickercolor-picker | ridiculous | Components | Free | no deps · 11 files |
