Text (text)

It is text. You can define its color, its size, its font...

const text = canvasUI.view.new("text-1", "text")

text.set("text", "Hello World!")

text.set("font", {
  family: "Poppins",
  size: 24,
  weight: 700,
})

text.set("color", "#14213d")
text

Properties

text

It is the text that has to draw. Its default value is:

"Text"

font

It is the font of the text. It is an object that has these properties:

  • family: It is the font family of the text.
  • size: It is the font size of the text.
  • weight: It is the font weight of the text.

Its default value is:

{
  family: "Courier New",
  size: 16,
  weight: 400
}

color

It is the color of the text. Its default value is:

"#000"

align

This property is useful when the text doesn't fit in its parent. It defines how the text has to be aligned. It is an object with these properties:

  • horizontal: It defines the horizontal alignment and its values can be "left", "middle" and "right".
  • vertical: It defines the vertical alignment and its values can be "top", "middle" and "bottom".

Its default value is:

{
  horizontal: "left",
  vertical: "middle"
}