Skip to main content

TextSublayer

Text sublayer nodes are pared-back versions of text nodes: they have most text properties (except textAlignVertical and textAutoResize, which are not editable on these nodes' text sublayers), as well as fills. They aren't resizable or repositionable.

You set text content as you would for any other text node (e.g. sticky.text.characters = 'some text'). As with all other text operations in Figma, you'll need to ensure fonts are loaded.

Basic traits

toString(): string

Returns a string representation of the node. For debugging purposes only, do not rely on the exact output of this string in production code.

View more →

parent: (BaseNode & ChildrenMixin) | null [readonly]

Returns the parent of this node, if any. This property is not meant to be directly edited. To reparent, see appendChild.

View more →
tip

Tip: parent will always return a ConnectorNode, ShapeWithTextNode, StickyNode, or TableCellNode

Text node traits

hasMissingFont: boolean [readonly]

Returns whether the text uses a font currently not available to the document.


paragraphIndent: number

The indentation of paragraphs (offset of the first line from the left). Setting this property requires the font the be loaded.


paragraphSpacing: number

The vertical distance between paragraphs. Setting this property requires the font to be loaded.


listSpacing: number

The vertical distance between lines of a list.


hangingPunctuation: boolean

Whether punctuation, like quotation marks, hangs outside the text box.


hangingList: boolean

Whether numbered list counters or unordered list bullets hang outside the text box.


fontSize: number | figma.mixed

The size of the font. Has minimum value of 1.


fontName: FontName | figma.mixed

The font family (e.g. "Inter"), and font style (e.g. "Regular"). Setting this property to a different value requires the new font to be loaded.


fontWeight: number | figma.mixed [readonly]

The weight of the font (e.g. 400 for "Regular", 700 for "Bold").


textCase: TextCase | figma.mixed

Overrides the case of the raw characters in the text node. Requires the font to be loaded.


textDecoration: TextDecoration | figma.mixed

Whether the text is underlined or has a strikethrough. Requires the font to be loaded.


letterSpacing: LetterSpacing | figma.mixed

The spacing between the individual characters. Requires the font to be loaded.


lineHeight: LineHeight | figma.mixed

The spacing between the lines in a paragraph of text. Requires the font to be loaded.


leadingTrim: LeadingTrim | figma.mixed

The removal of the vertical space above and below text glyphs. Requires the font to be loaded.


A HyperlinkTarget if the text node has exactly one hyperlink, or null if the node has none.


characters: string

The raw characters in the text node. Setting this property requires the font the be loaded.

View more →

insertCharacters(start: number, characters: string, useStyle?: 'BEFORE' | 'AFTER'): void

Insert characters at index start in the text.

View more →

deleteCharacters(start: number, end: number): void

Remove characters in the text from start (inclusive) to end (exclusive).

View more →

getRangeFontSize(start: number, end: number): number | figma.mixed

Get the fontSize from characters in range start (inclusive) to end (exclusive).


setRangeFontSize(start: number, end: number, value: number): void

Set the fontSize from characters in range start (inclusive) to end (exclusive). Requires the font to be loaded.


getRangeFontName(start: number, end: number): FontName | figma.mixed

Get the fontName from characters in range start (inclusive) to end (exclusive).


setRangeFontName(start: number, end: number, value: FontName): void

Set the fontName from characters in range start (inclusive) to end (exclusive). Requires the new font to be loaded.


getRangeFontWeight(start: number, end: number): number | figma.mixed

Get the fontWeight from characters in range start (inclusive) to end (exclusive).


getRangeAllFontNames(start: number, end: number): FontName[]

Get the fontNames from characters in range start (inclusive) to end (exclusive).


getRangeTextCase(start: number, end: number): TextCase | figma.mixed

Get the textCase from characters in range start (inclusive) to end (exclusive).


setRangeTextCase(start: number, end: number, value: TextCase): void

Set the textCase from characters in range start (inclusive) to end (exclusive). Requires the font to be loaded.


getRangeTextDecoration(start: number, end: number): TextDecoration | figma.mixed

Get the textDecoration from characters in range start (inclusive) to end (exclusive).


setRangeTextDecoration(start: number, end: number, value: TextDecoration): void

Set the textDecoration from characters in range start (inclusive) to end (exclusive). Requires the font to be loaded.


getRangeLetterSpacing(start: number, end: number): LetterSpacing | figma.mixed

Get the letterSpacing from characters in range start (inclusive) to end (exclusive).


setRangeLetterSpacing(start: number, end: number, value: LetterSpacing): void

Set the letterSpacing from characters in range start (inclusive) to end (exclusive). Requires the font to be loaded.


getRangeLineHeight(start: number, end: number): LineHeight | figma.mixed

Get the lineHeight from characters in range start (inclusive) to end (exclusive).


setRangeLineHeight(start: number, end: number, value: LineHeight): void

Set the lineHeight from characters in range start (inclusive) to end (exclusive). Requires the font to be loaded.


Get the hyperlink from characters in range start (inclusive) to end (exclusive). Returns a HyperlinkTarget if the range contains exactly one hyperlink, or null if the range contains none.


Set the hyperlink from characters in range start (inclusive) to end (exclusive). Removes the hyperlink in range if value is null.


getRangeFills(start: number, end: number): Paint[] | figma.mixed

Get the fills from characters in range start (inclusive) to end (exclusive).


setRangeFills(start: number, end: number, value: Paint[]): void

Set the fills from characters in range start (inclusive) to end (exclusive). Requires font to be loaded.


getRangeTextStyleId(start: number, end: number): string | figma.mixed

Get the textStyleId from characters in range start (inclusive) to end (exclusive).


setRangeTextStyleId(start: number, end: number, value: string): void

Set the textStyleId from characters in range start (inclusive) to end (exclusive). Requires the font to be loaded.


getRangeFillStyleId(start: number, end: number): string | figma.mixed

Get the fillStyleId from characters in range start (inclusive) to end (exclusive).


setRangeFillStyleId(start: number, end: number, value: string): void

Set the fillStyleId from characters in range start (inclusive) to end (exclusive). Requires the font to be loaded.


getRangeListOptions(start: number, end: number): TextListOptions | figma.mixed

Get the textListOptions from characters in range start (inclusive) to end (exclusive). Returns a TextListOptions


setRangeListOptions(start: number, end: number, value: TextListOptions): void

Set the textListOptions from characters in range start (inclusive) to end (exclusive).


getRangeIndentation(start: number, end: number): number | figma.mixed

Get the indentation from characters in range start (inclusive) to end (exclusive).


setRangeIndentation(start: number, end: number, value: number): void

Set the indentation from characters in range start (inclusive) to end (exclusive).


getStyledTextSegments<StyledTextSegmentFields extends (keyof Omit< StyledTextSegment, 'characters' | 'start' | 'end' >)[]>(fields: StyledTextSegmentFields, start?: number, end?: number): Array<Pick<StyledTextSegment, StyledTextSegmentFields[number] | 'characters' | 'start' | 'end'>>

Get text segments along with the desired text properties (font size, text case, etc...)

View more →

fills: ReadonlyArray<Paint> | figma.mixed

The paints used to fill the area of the shape. For help on how to change this value, see Editing Properties.

View more →

fillStyleId: string | figma.mixed

The id of the PaintStyle object that the fills property of this node is linked to.

View more →