Vue-diff is a Vue 3 component designed for rendering code differences in a user-friendly interface. It offers both split (side-by-side) and unified (inline) viewing modes, similar to those found in popular version control interfaces like GitHub Desktop. The component leverages `diff-match-patch` for its core diffing algorithm and `highlight.js` for robust syntax highlighting across various programming languages. Key features include support for customizable light and dark themes, virtual scrolling to efficiently handle large text comparisons, and a folding view for improved readability. It ships with TypeScript types, ensuring a good developer experience in TypeScript projects. The current stable version is 1.2.4, released in June 2022. While functional, its release cadence appears to be slow, suggesting a maintenance-focused development status rather than active feature expansion.
npm install vue-diffVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to install and register `vue-diff` as a Vue 3 plugin, then use the `<Diff>` component to display a side-by-side comparison of two TypeScript code snippets with dark theme and virtual scrolling.
Ensure your project is a Vue 3 application. If not, consider migrating to Vue 3 or finding a Vue 2 compatible diff library.
Review the GitHub repository's issue tracker for active issues or known limitations before integrating into critical production paths. Be prepared to fork or contribute if specific new features or urgent bug fixes are needed.
Refer to the 'Custom theme' section in the documentation. Define your custom theme as a CSS class (e.g., `.my-custom-theme`) and pass its name (e.g., `'custommy-custom-theme'`) to the `theme` prop.
Ensure you have called `app.use(VueDiff);` (or `app.use(VueDiff, { componentName: 'YourComponentName' });`) in your main application file (e.g., `main.ts` or `main.js`) before mounting the app.Add `import 'vue-diff/dist/index.css';` to your main application entry file (e.g., `main.ts` or `main.js`) or within a global style sheet.
Check the list of default supported languages in the `vue-diff` documentation. If your language is not listed, refer to the 'Extend languages' section to register additional `highlight.js` languages.