Back to Skills

pixijs-scene-text

Use this skill when rendering text in PixiJS v8. Covers Text for canvas-quality styled labels, BitmapText for cheap per-frame updates via glyph atlas, HTMLText for HTML/CSS markup via SVG, SplitText and SplitBitmapText for per-character animation, TextStyle, tagStyles, constructor options, TextOptions, HTMLTextOptions, BitmapText, SplitTextOptions, SplitBitmapTextOptions. Triggers on: Text, BitmapText, HTMLText, SplitText, SplitBitmapText, TextStyle, HTMLTextStyle, BitmapFont.install, tagStyles,

255stars14forksUpdated 6/26/2026

Security Assessment

Safe(100/100)
Security Score100/100

About pixijs-scene-text

Covers the five text-rendering classes available in PixiJS v8, each balancing styling fidelity, performance, and animation differently. Text renders to a canvas for full CSS-style fidelity, BitmapText reads from a pre-generated glyph atlas for cheap per-frame updates, HTMLText renders an HTML fragment via an SVG foreignObject for rich markup, and SplitText and SplitBitmapText wrap the first two classes to expose per-character, per-word, and per-line containers for animation. All five use options-object constructors of the form new Text({ text, style, ... }); the v7 positional (string, style) form is removed. All text classes are leaf nodes that cannot have children, so multiple instances must be wrapped in a Container to be grouped.

The guidance is organized around choosing the right variant for a workload. Use Text for high-quality static or infrequently updated labels such as titles, menus, dialog, and error messages. Use BitmapText for scores, timers, or any value that changes every frame, since updates only reposition quads instead of re-rasterizing a canvas. Use HTMLText for mixed formatting with real HTML tags like b, i, and br. Both Text and HTMLText support inline colored tags through style.tagStyles, which are only parsed when tagStyles has entries. For per-character animation, SplitText suits short strings and SplitBitmapText suits long strings or many instances. CJK, Arabic, and emoji-heavy text should use Text or HTMLText because the glyph set is too large for a single bitmap atlas.

The document includes an update-cost comparison table, notes on MSDF (Multi-channel Signed Distance Field) fonts that stay sharp at any size, and BitmapFont.install for pre-generating an atlas. Custom fonts are loaded through Assets.load with a family in the data option before setting style.fontFamily. Common mistakes are flagged by severity, including updating Text.text every frame, using positional constructor arguments, omitting the import of pixi.js/text-bitmap under aggressive tree-shaking, and adding children to text instances.

FAQ

Which text class should I use for a score or timer that updates every frame?

Use BitmapText. Its updates only reposition quads rather than redrawing a canvas and re-uploading to the GPU, so changing the text per-frame is very cheap. SplitBitmapText is similarly cheap for animated per-character strings.

Does PixiJS v8 still support the positional new Text(string, style) constructor?

No. v8 removed the positional (string, style) form. Every text class now uses an options-object constructor, for example new Text({ text: "Hello", style: { fontSize: 24 } }).

How do I load and use a custom font?

Load it first with Assets.load, passing the family in the data option (for example Assets.load({ src: 'font.woff2', data: { family: 'MyFont' } })), then set style.fontFamily to that family. This works for Text and HTMLText.

Can I add child display objects to a text instance?

No. Every text class sets allowChildren = false, so text instances are leaf nodes. To group text with other content, wrap the instances in a Container.

Why does Assets.load('font.fnt') sometimes return raw data instead of a usable bitmap font?

Under skipExtensionImports or aggressive tree-shaking, the bitmap text extension may be stripped, so the load silently returns raw data. Add import 'pixi.js/text-bitmap' to your custom build; the standard pixi.js bundle already includes it.

All Files

6 files
SKILL.md8.1 KB
View
references/split-text.md6.6 KB
View
references/text.md10.6 KB
View
references/html-text.md7.2 KB
View
references/split-bitmap-text.md7.9 KB
View
references/bitmap-text.md11.2 KB
View

Install pixijs-scene-text

Download and extract the skill files to your .claude/skills/ directory.

Quick Setup:

  1. Copy the skill folder to .claude/skills/
  2. Claude will automatically detect and use the skill