sheengemologic ui
All components

DiffViewer

Shows a searchable, copyable unified line diff with bounded computation and virtualized large-content DOM.@gemologic/sheen-code · content

Playground

This example has no scalar controls. Its validated source remains interactive below.
Configuration changes
4 of 4 lines
port = 80
enabled = false
port = 443
enabled = true
<DiffViewer oldText={before} newText={after} label="Configuration changes" oldLabel="before.toml" newLabel="after.toml" />

Variant matrix

Configuration change
Configuration changes
4 of 4 lines
port = 80
enabled = false
port = 443
enabled = true

Anatomy

Package
@gemologic/sheen-code
Source
packages/code/src/DiffViewer.tsx
Tokens
  • --sheen-color-bg-raised
  • --sheen-color-danger-subtle
  • --sheen-color-success-subtle
  • --sheen-font-mono

Accessibility

Role: named region containing a focusable virtual list and listitemsKeyboard: Tab, Shift+Tab, Enter, Space, PageUp, PageDown, Home, End

Do

  • Keep the viewer mounted when accepted source refreshes.
  • Use labels that identify both revisions.

Do not

  • Do not rely on red and green alone; prefixes and accessible row labels encode change kind.
  • Do not use the viewer as an editable merge tool.

Generated props

NameTypeDefaultDescription
oldText *stringComplete accepted source before the change.
newText *stringComplete accepted source after the change.
label *stringRequired accessible viewer and line-list name.
oldLabelstringBeforeLabel used by the copied unified diff header.
newLabelstringAfterLabel used by the copied unified diff header.
searchablebooleantrueShows a debounced line search that does not mutate the source.
copyablebooleantrueCopies the complete unified diff.
initialHeightnumber360Deterministic SSR and initial viewport height in pixels from 120 to 1200.
lineHeightnumber22Fixed virtual row height in pixels from 16 to 48.
onCopyError(error: unknown) => voidReceives Clipboard API failures without exposing raw errors in the UI.
Native Solid/HTML attributes remain available and are omitted from this authored-prop view.