Skip to content
synccn

Code Diff

Unified or split view of changes between two files.

components/ui/button.jsx+3−2
1-export function Button({ children }) {
1+export function Button({ children, loading }) {
2 return (
3- <button className="btn">
3+ <button className="btn" disabled={loading}>
4+ {loading && <Spinner />}
5 {children}
6 </button>
7 );
8 }

Installation

$ pnpm dlx shadcn@latest add @synccn/code-diff

First time in this project? Connect synccn with one command.

Usage

import { CodeDiff } from "@/components/ui/code-diff";<CodeDiff before={a} after={b} filename="button.jsx" />

API reference

Generated from the component's TypeScript types, so it always matches the code.

CodeDiff

Unified or split view of the changes between two versions of a file.

  • beforerequired
    string

    Original text.

  • afterrequired
    string

    Changed text.

  • filename
    string

    Shown in the header.

  • defaultView
    "unified" | "split"

    Default "unified"

    View shown first.

  • className
    string

    Extra classes for the root element.

Dependencies

Read from the component's imports when the site builds. The CLI installs all of these for you.

Helpers

npm packages

Accessibility

From the source

Read from this component's code when the site builds, so it can't drift.

  • ARIA attributes: aria-pressed
  • Keys handled: Space