Skip to main content

Text

Use Text to draw text.

If the text exceeds the display area, an ellipsis () is added after the last visible character in the last line.

Supported CSS styles

propertynote
font
fontFamily
fontStyle
fontVariant
fontWeight
fontStretch
fontSizeNumber type (px) only
lineHeightNumber type (px) only
colorCSS <color> Type
maxLinesMaximum number of lines
textAlignOnly support left | center | right
Live Editor
function TextExample () {
  const { Canvas, Text } = importCanvasUIPackages()

  const [text, setText] = React.useState('The quick brown 🦊 jumps over the lazy 🐶')
  const [style, setStyle] = React.useState({
    width: 100,
    height: 50,
    maxLines: 1,
    borderWidth: 1,
    borderColor: 'red'
  })

  return (
    <div style={{ height: '100px' }}>
      <Canvas>
        <Text
          style={ style }
        >
        { text }
        </Text>
      </Canvas>
    </div>
  )
}
Result
Loading...