TextBlock Class @beta
Represents a formatted text document consisting of a series of Paragraphs, each laid out on a separate line and containing their own content. No word-wrapping is applied to the document unless a width greater than zero is specified.
@see TextAnnotation to position a text block as an annotation in 2d or 3d space.
Extends
Methods
Name | Description | |
---|---|---|
appendParagraph(props?: ParagraphProps, seedFromLast: booleanfalse): Paragraph | Add and return a new paragraph. | |
appendRun(run: Run): void | Append a run to the last Paragraph in this block. | |
clearStyleOverrides(options?: ClearTextStyleOptions): void | Reset any styleOverrides applied to this component. | |
clone(): TextBlock | Create a deep copy of this component. | |
equals(other: TextBlockComponent): boolean | Returns true if this is equivalent to other . |
|
stringify(options?: TextBlockStringifyOptions): string | Compute a string representation of the document's contents by concatenating the string representations of each of its children, separated by paragraphBreak. | |
toJSON(): TextBlockProps | Convert this component to its JSON representation. | |
create(props?: Omit<TextBlockProps, "type">): TextBlock Static | Create a text block from its JSON representation. |
Properties
Name | Type | Description | |
---|---|---|---|
children Readonly | Paragraph[] | ||
isEmpty Accessor ReadOnly | boolean | Returns true if every paragraph in this text block is empty. | |
width | number | The width of the document in meters. |
Inherited properties
Name | Type | Inherited from | Description |
---|---|---|---|
isWhitespace Accessor Inherited ReadOnly | boolean | TextBlockComponent | Returns true if the string representation of this component consists only of whitespace characters. Useful for checking if the component is visually empty (producing no graphics) or contains only spaces, tabs, or line breaks. |
overridesStyle Accessor Inherited ReadOnly | boolean | TextBlockComponent | Returns true if styleOverrides specifies any deviations from the TextBlock's AnnotationTextStyle. |
styleOverrides Accessor Inherited | TextStyleSettingsProps | TextBlockComponent | Deviations in individual properties of the TextStyleSettings in the AnnotationTextStyle. For example, if the style uses the "Arial" font, you can override that by settings styleOverrides.font.name to "Comic Sans". |
Defined in
Last Updated: 07 October, 2025
Found something wrong, missing, or unclear on this page? Raise an issue in our repo.