Skip to main content

Text

See the Text Basics guide for an introduction to Text in Presenter.js.

Text

Text is a SlideObject that can render text on a slide.

Text supports all of the properties of TextStyle (described next in this document), plus the properties below:

PropertyTypeDescriptionDefault
alignmentAlignmentDefines how lines of text should be alignedAlignment.LEFT
anchorAnchorDefines which point of text sits at (x, y)Anchor.TOP_LEFT
descriptionstring | nullAccessible description of textString version of text content
lengthnumber | nullNumber of visible characters of textnull (shows all)
lineSpacingnumberRelative amount of space between lines1
opacitynumberOpacity of text1
textTextContentText to render on slide""
xnumberHorizontal position of text0
ynumberVertical position of text0

TextStyle

TextStyle defines additional properties that can be used to style a full Text object or individual units of text. TextStyle supports the following properties:

PropertyTypeDescriptionDefault
colorColorColor to use to render textColor.BLACK
fontFamilystringFont name or comma-separated list of fontssans-serif
fontSizenumberSize to use to render text100
fontStyleFontStyleStyle of font (e.g. normal, italic)FontStyle.NORMAL
fontWeightFontWeight | numberWeight of font (e.g. 400 is normal, 700 is bold)FontWeight.NORMAL
ligaturesbooleanWhether to render text with ligaturesfalse
subscriptbooleanWhether to render text as superscriptfalse
superscriptbooleanWhether to render text as subscriptfalse

TextContent and TextUnit

The text content of a Text object has type TextContent. TextContent can either be a string (representing a single line of text with consistent styling) or it can be an array of lines of text.

If TextContent is an array of lines of text, each line itself is an array of TextUnit | string. A string represents part of a line that retains the same styling as the Text object overall. A TextUnit represents part of a line that can have different text styling.

The full TypeScript types are given below:

interface TextUnit extends Partial<TextStyle> {
text: string;
}

type TextContent = string | (TextUnit | string)[][];