Methane@methane-ui/*
CSS LayoutsComponentsSkillsTheme BuilderGitHub
← All Components

<mth-diff-viewer>

@methane-ui/code~7.9 KB brotli shell + lazy engine~2.0 KB shell · lazy engine chunk

Unified and side-by-side line diff viewer with LCS diffing, keyboard hunk navigation, accessible semantics, and --mth-* token synchronization.

When NOT to use: Use a lightweight @methane-ui/css layout class instead of a custom element when static CSS suffices.

Live Interactive Preview

Interactive StageLive Custom Element · <mth-diff-viewer> (@methane-ui/code)
Ready · interact with <mth-diff-viewer>, or toggle Theme, Direction (LTR/RTL), or props above.

Multi-Framework Playground & Snippets

<script type="module" src="@methane-ui/code/diff-viewer"></script>
<mth-diff-viewer view="unified"></mth-diff-viewer>

Properties & Attributes

PropertyAttributeTypeDefaultDescription
originaloriginalstring""original property.
modifiedmodifiedstring""modified property.
filenamefilenamestring""filename property.
labellabelstring""label property.
viewview'unified' | 'split'"unified"view property.

Events

EventDetail TypeDescription
mth-view-change{ view: unknown }Emitted event mth-view-change.
mth-hunk-change{ hunkIndex: number; total: number }Emitted event mth-hunk-change.

APG Keyboard Matrix

KeyDirectionWhenExpected Behavior
ArrowRightltrtoolbar button focusedmoves focus to next control
ArrowLeftrtltoolbar button focusedmoves focus to next control

Accessibility Checklist

CategoryRequirementVerified By
ariaAll aria-* IDREFs resolve within the same DOM root (ADR-003).scanSameRootAria
focusdelegatesFocus: true with zero host internals.role (ADR-014).lint-plugin & spec-compiler
contrastRenders legible borders, focus outlines, and selection indicators under forced-colors: active.Playwright forced-colors matrix
keyboardImplements all 2 APG keyboard transitions across LTR/RTL.mth-diff-viewer.spec.test.ts
statesExposes ElementInternals CustomStateSet flags: :state(split).Conformance suite
i18nRoutes 7 UI/ARIA strings through @methane-ui/core i18n catalog.Locale context test