Skip to content
Blocks Diff

Diff

Before and after values.

On this page

Examples

Typed comparisons

KlyDiffItem.Compare builds an item from two typed values and decides Changed by equality. The values are formatted when the block renders, with the Culture of the block.

English

Plan
StarterTeam
Seats
12
Price
1,200.501,500.00
Due
3/5/20264/1/2026
RoleNeeds approval
MemberAdmin

German

Plan
StarterTeam
Price
1.200,501.500,00
Due
05.03.202601.04.2026
RoleNeeds approval
MemberAdmin
Razor
<div class="grid w-full gap-4 md:grid-cols-2">
    <KlyDiff Title="English" Surface="KlySurface.Bordered" Culture="@_en" ShowUnchanged Items="@_items" />
    <KlyDiff Title="German" Surface="KlySurface.Bordered" Culture="@_de" Items="@_items" />
</div>

@code {
    private readonly System.Globalization.CultureInfo _en = System.Globalization.CultureInfo.GetCultureInfo("en-US");
    private readonly System.Globalization.CultureInfo _de = System.Globalization.CultureInfo.GetCultureInfo("de-DE");

    private readonly KlyDiffItem[] _items =
    [
        KlyDiffItem.Compare("Plan", "Starter", "Team"),
        KlyDiffItem.Compare("Seats", 12, 12),
        KlyDiffItem.Compare("Price", 1200.5m, 1500m, "N2"),
        KlyDiffItem.Compare("Due", new DateOnly(2026, 3, 5), new DateOnly(2026, 4, 1), "d"),
        new("Role", "Member", "Admin") { Note = new KlyBadgeItem("Needs approval") },
    ];
}

API

KlyDiff

Before and after values per field, with unchanged fields hidden unless ShowUnchanged is set.

Parameters

Name Type Default Description
Class string Classes added to the root element, merged last so they win over the theme.
Culture CultureInfo The culture that formats the values of the items built with IEqualityComparer{``0}) . Defaults to the format culture of the locale in effect.
Items IReadOnlyList<KlyDiffItem> The fields, as KlyDiffItem .
Loading bool false Shows a skeleton placeholder instead of the content.
ShowUnchanged bool false Shows the fields whose Changed is false ( false by default).
Surface KlySurface? The surface treatment. Plain when not set. Values: Plain, Muted, Bordered, Elevated.
Title string The title of the block.
Ui DiffUi Per-instance class overrides of the slots of the diff, see DiffUi . They are merged after the theme and the Class parameter wins on the root slot.

Ui slots

Ui takes a DiffUi with one class string per slot, merged after the theme.

Slot Styles
Root Classes merged into the root slot of KlyDiff , after the theme and the app configuration.
Title Classes merged into the title slot of KlyDiff , after the theme and the app configuration.
List Classes merged into the list slot of KlyDiff , after the theme and the app configuration.
Item Classes merged into the item slot of KlyDiff , after the theme and the app configuration.
Label Classes merged into the label slot of KlyDiff , after the theme and the app configuration.
Values Classes merged into the values slot of KlyDiff , after the theme and the app configuration.
Before Classes merged into the before slot of KlyDiff , after the theme and the app configuration.
Arrow Classes merged into the arrow slot of KlyDiff , after the theme and the app configuration.
After Classes merged into the after slot of KlyDiff , after the theme and the app configuration.
Unchanged Classes merged into the unchanged slot of KlyDiff , after the theme and the app configuration.
Skeleton Classes merged into the skeleton slot of KlyDiff , after the theme and the app configuration.