Skip to main content

Common Examples

To use the DiffValue, import it from @servicetitan/anvil2-ai-kit and pass the previous value through from and the proposed value through to.

Automatic layout

DiffValue uses inline layout for short, single-line values. It switches to block layout when either value exceeds 80 characters or contains a newline. Pass layout to override the automatic choice.

Empty and removed values

Omit from, pass null, or pass whitespace to render the localized empty label. Do the same for to to render the localized removed label.

Truncation

Block layout uses TruncatedText. Set truncateLines to control the collapsed line limit.

Internationalization

DiffValue uses three messages:
  • ai-kit.diffValue.empty
  • ai-kit.diffValue.removed
  • ai-kit.diffValue.changedFromTo
English is the default. Mount AiKitIntlProvider inside CartoTheme to switch locale or override these strings. The changedFromTo message receives {from} and {to} values.

React Accessibility

  • A visually hidden localized summary announces the relationship as “Changed from X to Y.”
  • Inline layout hides duplicate visual values from assistive technology.
  • Block layout keeps Show more and Show less controls reachable when either value is truncated.
  • The arrow is decorative and hidden from assistive technology.
Last modified on August 28, 2026