Skip to main content

Common Examples

To use the TruncatedText, import it from @servicetitan/anvil2-ai-kit and pass content through the required text prop. It uses body Text styling and clamps to two lines by default.

Line limit

Set truncateLines to the maximum visible lines when collapsed. Use 0 to disable truncation.

Expand and collapse

When content overflows, TruncatedText adds Show more and Show less controls. The full content remains in the DOM; clipping is visual only.

Body size

The size prop accepts the body type scale: "fine", "compact", "regular" (default), and "featured".

Highlighted

Set highlighted to apply the suggested-change treatment.

Internationalization

TruncatedText uses ai-kit.text.showMore and ai-kit.text.showLess for its controls. English is the default. Mount AiKitIntlProvider inside CartoTheme to switch locale or override either string.

React Accessibility

  • Show more and Show less expose expansion state with aria-expanded and associate the control with its content through aria-controls.
  • Focus moves between Show more and Show less after expansion changes, preserving keyboard position.
  • The full text remains available in the DOM while collapsed.
Last modified on August 28, 2026