Componenteditors0.72 KB gzipZero dependencies

Diff Editor

Editable side-by-side diff view.

Preview

Live Preview
Open ↗

Installation

Tokens guide →

Add to your project via CLI (zero dependencies, code you own):

npx bigbullui add diff-editor

Or install the full npm package:

npm install bigbullui

Usage

tsx3 lines
import { DiffEditor } from "@/components/ui/diff-editor"; <DiffEditor />

Source code

diff-editor.tsx + 1 helper

Zero third-party dependencies (2 local files shown in tabs below).

tsxdiff-editor.tsx62 lines
"use client"; import * as React from "react";import { cn } from "./lib/utils"; export interface DiffEditorProps extends React.HTMLAttributes<HTMLDivElement> {  before: string;  after: string;  readOnly?: boolean;  onBeforeChange?: (v: string) => void;  onAfterChange?: (v: string) => void;} /** Side-by-side editable diff comparison editor. */export function DiffEditor({ before = "", after = "", readOnly, onBeforeChange, onAfterChange, className, ...props }: DiffEditorProps) {  const beforeLines = before.split("\n");  const afterLines = after.split("\n");  const maxLines = Math.max(beforeLines.length, afterLines.length);

Props

Interactive Prop Playground

Tweak parsed AST props below to generate ready-to-paste JSX.

tsx3 lines
import { DiffEditor } from "@/components/ui/diff-editor"; <DiffEditor />
PropTypeDescription
beforestringConfigures before. (Default: "")
afterstringConfigures after. (Default: "")
readOnlybooleanMakes the control non-editable while remaining focusable.
onBeforeChange(v: string) => voidCallback invoked on before change.
onAfterChange(v: string) => voidCallback invoked on after change.