Skip to content

Use Text component

Common example:

html
<Text text="Hello World" size="20" />

Properties

You can use all properties from Display Object

style

Style object from PixiJS Text

text

text?: string

Le texte à afficher

color

color?: string

La couleur du texte (raccourci pour style.fill)

size

size?: string

La taille de la police (raccourci pour style.fontSize)

fontFamily

fontFamily?: string

La famille de police à utiliser (raccourci pour style.fontFamily)

typewriter

html
<Text text="Hello World" typewriter="{}" />

typewriter?: { speed?: number; onComplete?: () => void; skip?: Trigger; }

Object to configure typewriter effect:

  • speed: Animation speed of the typewriter effect
  • onComplete: Callback function when the animation completes
  • skip: Trigger to skip the current animation

Example with skip trigger

html
<Text text="Hello World" typewriter={ { skip } } />

<script>
import { trigger } from 'canvasengine'

const skip = trigger()

// skip the typewriter effect
skip.start()
</script>

Common Properties

PropertyTypeDescription
xnumberX-coordinate position of the display object.
ynumberY-coordinate position of the display object.
widthnumberWidth of the display object.
heightnumberHeight of the display object.
scaleobjectScale of the display object.
anchorobjectAnchor point of the display object.
skewobjectSkew of the display object.
tintnumberTint color of the display object.
rotationnumberRotation of the display object in radians.
anglenumberRotation of the display object in degrees.
zIndexnumberZ-index of the display object.
roundPixelsbooleanWhether to round pixel values.
cursorstringCursor style when hovering over the display object.
visiblebooleanVisibility of the display object.
alphanumberAlpha transparency of the display object.
pivotobjectPivot point of the display object.
flexDirectionstringFlex direction for layout. Possible values: 'row', 'column', 'row-reverse', 'column-reverse'.
flexWrapstringFlex wrap for layout. Possible values: 'wrap', 'nowrap', 'wrap-reverse'.
justifyContentstringJustify content for layout. Possible values: 'flex-start', 'flex-end', 'center', 'space-between', 'space-around'.
alignItemsstringAlign items for layout. Possible values: 'auto', 'flex-start', 'flex-end', 'center', 'stretch', 'baseline', 'space-between', 'space-around'.
alignContentstringAlign content for layout. Possible values: 'flex-start', 'flex-end', 'center', 'stretch', 'baseline', 'space-between', 'space-around'.
alignSelfstringAlign self for layout. Possible values: 'auto', 'flex-start', 'flex-end', 'center', 'stretch', 'baseline', 'space-between', 'space-around'.
marginobjectMargin for layout.
paddingobjectPadding for layout.
gapobjectGap for layout.
borderobjectBorder for layout.
positionTypestringPosition type for layout.
filtersarrayFilters applied to the display object.
maskOfElementElement that this display object masks.
blendModestringBlend mode for rendering.
filterAreaobjectFilter area for rendering.

shadow

PropertyTypeDescription
PropertyTypeDescription
blurnumberBlur strength.
colornumberColor of the shadow.
offsetobjectOffset of the shadow.
qualitynumberQuality of the shadow.