{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "image-compare",
  "title": "Image Compare",
  "author": "VenusUI",
  "description": "A before/after slider with a draggable divider that also works with the keyboard.",
  "files": [
    {
      "path": "registry/default/ui/image-compare.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\n\nimport { cn } from \"@/lib/utils\"\n\ninterface ImageCompareProps {\n  /** Shown on the left of the divider, e.g. an image before editing. */\n  before: React.ReactNode\n  /** Shown on the right of the divider. */\n  after: React.ReactNode\n  /** Short names for each side, shown as labels and used in the slider's accessible name. */\n  beforeLabel?: string\n  afterLabel?: string\n  /** Starting divider position, 0–100. */\n  defaultPosition?: number\n  className?: string\n}\n\n/**\n * Two layers with a draggable divider to compare them. The divider is a real\n * range input, so it works with mouse, touch and keyboard (arrows, Home, End).\n */\nfunction ImageCompare({\n  before,\n  after,\n  beforeLabel = \"Before\",\n  afterLabel = \"After\",\n  defaultPosition = 50,\n  className,\n}: ImageCompareProps) {\n  const [position, setPosition] = React.useState(defaultPosition)\n\n  return (\n    <div\n      data-slot=\"image-compare\"\n      className={cn(\"group relative isolate aspect-video w-full overflow-hidden rounded-xl border select-none\", className)}\n    >\n      <div className=\"absolute inset-0\">{after}</div>\n      <div className=\"absolute inset-0\" style={{ clipPath: `inset(0 ${100 - position}% 0 0)` }}>\n        {before}\n      </div>\n\n      <span className=\"absolute top-3 left-3 rounded-md bg-background/80 px-2 py-0.5 text-xs font-medium\">{beforeLabel}</span>\n      <span className=\"absolute top-3 right-3 rounded-md bg-background/80 px-2 py-0.5 text-xs font-medium\">{afterLabel}</span>\n\n      <div aria-hidden=\"true\" className=\"pointer-events-none absolute inset-y-0 w-0.5 -translate-x-1/2 bg-background\" style={{ left: `${position}%` }}>\n        <span className=\"absolute top-1/2 left-1/2 flex size-8 -translate-x-1/2 -translate-y-1/2 items-center justify-center rounded-full border bg-background shadow-sm group-has-[input:focus-visible]:ring-3 group-has-[input:focus-visible]:ring-ring/50\">\n          <svg viewBox=\"0 0 16 16\" className=\"size-4 text-muted-foreground\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.5\">\n            <path d=\"M6 4 2 8l4 4M10 4l4 4-4 4\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n          </svg>\n        </span>\n      </div>\n\n      <input\n        type=\"range\"\n        min={0}\n        max={100}\n        step={1}\n        value={position}\n        onChange={(event) => setPosition(Number(event.target.value))}\n        aria-label={`Compare ${beforeLabel} and ${afterLabel}`}\n        aria-valuetext={`${Math.round(position)}% ${beforeLabel}`}\n        className=\"absolute inset-0 z-10 size-full cursor-ew-resize appearance-none opacity-0\"\n      />\n    </div>\n  )\n}\n\nexport { ImageCompare, type ImageCompareProps }\n",
      "type": "registry:ui"
    }
  ],
  "meta": {
    "version": "0.1.0"
  },
  "categories": [
    "interactive"
  ],
  "type": "registry:ui"
}