TextCompareForBlazor 1.3.0
dotnet add package TextCompareForBlazor --version 1.3.0
NuGet\Install-Package TextCompareForBlazor -Version 1.3.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="TextCompareForBlazor" Version="1.3.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TextCompareForBlazor" Version="1.3.0" />
<PackageReference Include="TextCompareForBlazor" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add TextCompareForBlazor --version 1.3.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: TextCompareForBlazor, 1.3.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package TextCompareForBlazor@1.3.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=TextCompareForBlazor&version=1.3.0
#tool nuget:?package=TextCompareForBlazor&version=1.3.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
TextCompareForBlazor
TextCompareForBlazor is a lightweight, client-side Blazor (WebAssembly or Server) component for visually comparing two text blobs side-by-side with selectable diff granularity (Character / Word / Line), optional whitespace normalization, synchronized scrolling, line alignment (with gap placeholders), and customizable theming.
Framework Support
- .NET 8.0
- .NET 9.0
- .NET 10.0
What's New in 1.3.0
- Added multi-targeting: net9.0, net10.0
- Now supports .NET 8.0, 9.0, and 10.0
- No API changes; purely additive framework support
What's New in 1.2.2:
- Fixed issue with selected line highlighting bleeding into gutter area.
- fixed issue with captions shifting left when hidding line numbers.
What's New in 1.2.1
- Minor UI polish and reliability fixes for upload buttons and search scrolling.
What's New in 1.2.0
- Added upload buttons in captions (above gutters) for left/right panels.
- Display File Names in captions.
- Display �Last Modified� dates right-justified in captions.
- Clear buttons to reset panels.
- Caption layout and styles refined; minor UI polish.
What's New in 1.1.0
- Collapsible unchanged regions with ellipsis rows (click to expand).
- Collapse contiguous unchanged sections from the gutter.
- Right-click context menu in text areas with context-aware actions:
- Expand all collapsed regions
- Collapse all expanded regions
- Search improvements: case-sensitive toggle and better scroll-into-view behavior.
- Unified font family and size across gutter and content via CSS variables.
- Minor fixes for line number alignment and scroll sync.
What's New in 1.0.3
- Unified font family and size applied to both gutter (line numbers) and text content via CSS variables.
- Toolbar dropdowns for Font and Size.
- Toolbar order: Search first, then Granularity/Whitespace, then Font; Sync toggle right-aligned.
- Typical, widely available monospace font stacks offered by default.
Usage: Unified Font Settings
Control the font family and size for the entire compare surface (both gutters and text areas). These parameters can be set directly or via toolbar dropdowns when ShowToolbar is true.
Features
- Side-by-side synchronized scroll viewing (toggleable)
- Granularity selector: Character, Word, or Line
- Word diff uses token mapping to preserve original spacing
- Intelligent line alignment (modified / inserted / deleted handling)
- Optional whitespace collapsing (
IgnoreWhitespace) - Optional NBSP width preservation for deleted/inserted tokens (
UseTokenPadding) - Line numbers (toggleable)
- Footer metrics: lines, words, characters, differences
- Fully styleable via parameters + CSS variable hooks
- Accessible structure: ARIA labels, focusable line items
Getting Started
Add a project/package reference to TextCompareForBlazor (project reference or NuGet, if published). Then:
Set originalText / modifiedText in your page/component C# code.
Minimal Example (.razor)
<TextCompareForBlazor.Components.SideBySide UserStyle="width:calc(100vw - 320px); height:calc(100vh - 180px);" LeftText="@OriginalText" RightText="@ModifiedText" />
@code {
string OriginalText = "...";
string ModifiedText = "...";
}
Component Parameters
| Name | Type | Default | Description |
|---|---|---|---|
LeftCaption |
string |
Original |
Caption above left panel. |
RightCaption |
string |
Modified |
Caption above right panel. |
LeftText |
string |
"" |
Source/original content. |
RightText |
string |
"" |
Target/modified content. |
ShowGranularitySelector |
bool |
true |
Shows the Character/Word/Line dropdown. |
ShowIgnoreWhitespace |
bool |
true |
Toggle to collapse whitespace runs. |
ShowSyncToggle |
bool |
true |
Toggle for scroll sync. |
ShowLineNumbers |
bool |
true |
Displays gutter line numbers. |
SyncScrolling |
bool |
true |
Initial sync state (can be toggled). |
IgnoreWhitespace |
bool |
false |
Collapses all whitespace to single spaces for comparison. |
UseTokenPadding |
bool |
false |
Pads deleted/inserted word tokens with NBSPs to retain horizontal alignment. |
ShowFooter |
bool |
true |
Shows metrics footer. |
Granularity |
DiffGranularity |
Character |
Current diff level: Character, Word, or Line. |
UserStyle |
string? |
width:auto; height:auto; |
Inline style appended to root container. |
ShowToolbar |
bool |
true |
Shows the toolbar containing Search, Granularity/Whitespace, Font controls, and Sync toggle. |
ShowSearch |
bool |
true |
Displays the search box, match count, navigation buttons, and clear action. |
ShowCaseSensitiveToggle |
bool |
true |
Displays the case-sensitive search toggle in the search group. |
CaseSensitiveSearch |
bool |
false |
When true, search uses case-sensitive matching. |