> A high-performance Svelte diff view component with GitHub-style UI
npm install @git-diff-view/svelte> A high-performance Svelte diff view component with GitHub-style UI


- ✅ Split & Unified views
- ✅ Syntax highlighting with full context
- ✅ Light & Dark themes
- ✅ Svelte 4+ support with Snippets
- ✅ Widget & extend data system with snippets
- ✅ High performance with Web Worker support
``bash`
npm install @git-diff-view/svelteor
pnpm add @git-diff-view/svelteor
yarn add @git-diff-view/svelte
`svelte
diffViewMode={DiffModeEnum.Split}
diffViewTheme="dark"
diffViewHighlight={true}
/>
`
File Comparison Mode
`svelte
`
Git Diff Mode
`svelte
`
`svelte`
| Prop | Type | Description |
|------|------|-------------|
| data | DiffData | Diff data with oldFile, newFile, and hunks |diffFile
| | DiffFile | Pre-processed diff file instance |diffViewMode
| | Split \| Unified | View mode (default: Split) |diffViewTheme
| | light \| dark | Theme (default: light) |diffViewHighlight
| | boolean | Enable syntax highlighting |diffViewWrap
| | boolean | Enable line wrapping |diffViewFontSize
| | number | Font size in pixels |diffViewAddWidget
| | boolean | Enable widget button |extendData
| | ExtendData | Additional data per line |renderWidgetLine
| | Snippet | Custom widget snippet |renderExtendLine
| | Snippet | Custom extend data snippet |
| Event | Payload | Description |
|-------|---------|-------------|
| onAddWidgetClick | { side, lineNumber } | Fired when widget button is clicked |
`typescript``
type DiffData = {
oldFile?: {
fileName?: string | null;
fileLang?: string | null;
content?: string | null;
};
newFile?: {
fileName?: string | null;
fileLang?: string | null;
content?: string | null;
};
hunks: string[];
};
Try it online: https://mrwangjusttodo.github.io/git-diff-view
MIT © MrWangJustToDo