- Implementation
- TruncatedText Props
Common Examples
To use theTruncatedText, 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
SettruncateLines 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
Thesize prop accepts the body type scale: "fine", "compact", "regular" (default), and "featured".Highlighted
Sethighlighted 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-expandedand associate the control with its content througharia-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.