@threlte/extras

<Text>

The <Text> component uses troika-three-text to render text.

Example

<script>
  import { Text } from '@threlte/extras'
  let value = ''
</script>

<input
  type="text"
  bind:value
/>
<Text text={value} />

<Text> is suspense-ready and will suspend while the font is loading. You can use the characters prop to preload a specific set of characters to prevent FOUC.

<script>
  import { Text, Suspense } from '@threlte/extras'
</script>

<Suspense>
  <Text
    text="HELLO WORLD"
    characters="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
  />

  {#snippet fallback()}
    <!-- show fallback content while font data is loading -->
  {/snippet}
</Suspense>

Component Signature

<Text> extends <T.Mesh> and supports all its props, slot props, bindings and events.

Props

name
type
required
description

anchorX
number | 'left' | 'center' | 'right' | string
no

anchorY
number | 'top' | 'top-baseline' | 'middle' | 'bottom-baseline' | 'bottom' | string
no

characters
string
no
The set of characters `<Text>` will preload while suspended.

clipRect
[number, number, number, number]
no

color
string | number | Color
no

curveRadius
number
no

depthOffset
number
no

direction
'auto' | 'ltr' | 'rtl'
no

fillOpacity
number
no

font
string
no

fontSize
number
no

glyphGeometryDetail
number
no

letterSpacing
number
no

lineHeight
number | string
no

material
Material | Material[]
no

maxWidth
number
no

outlineBlur
number | string
no

outlineColor
ColorRepresentation
no

outlineOffsetX
number | string
no

outlineOffsetY
number | string
no

outlineOpacity
number
no

outlineWidth
number | string
no

overflowWrap
'normal' | 'break-word' | 'normal'
no

sdfGlyphSize
number
no

strokeColor
ColorRepresentation | Color
no

strokeOpacity
number
no

strokeWidth
number | string
no

text
string
no

textAlign
'left' | 'right' | 'center' | 'justify'
no

textIndent
number
no

whiteSpace
'normal' | 'nowrap' | 'pre-wrap'
no