<!--
{
  "availability" : [
    "iOS: 18.0.0 -",
    "iPadOS: 18.0.0 -",
    "macCatalyst: 18.0.0 -",
    "macOS: 15.0.0 -",
    "tvOS: 26.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "RealityKit",
  "identifier" : "/documentation/RealityKit/TextComponent",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "RealityKit"
    ],
    "preciseIdentifier" : "s:17RealityFoundation13TextComponentV"
  },
  "title" : "TextComponent"
}
-->

# TextComponent

A component that draws 2D text at an entity’s location.

```
struct TextComponent
```

## Overview

`TextComponent` renders two-dimensional text in a RealityKit scene.
It creates a rounded rectangle mesh to serve as a canvas and draws an attributed string on the mesh. This component handles
everything required to render the text, including updating the plane transform, setting material parameters, and creating mesh components.

Set the component’s [`size`](/documentation/RealityKit/TextComponent/size) to define the area of the canvas in points. This setting also affects the size at which RealityKit
renders the text. The world-size of the canvas may be different than the value you specify because the component’s entity inherits its
parent’s transform, which may include scale changes that affect the final rendered size.

Text components use the CoreGraphics coordinate space: The origin is at the upper left of the canvas and positive
values extend down and to the right. You can’t specify an explicit backing-buffer size. RealityKit dynamically adjusts
the backing size to a value that results in high-fidelity text at its current location.

RealityKit lays out text using default `Foundation/AttributedString` behaviors and wraps text instead of
truncating it. It keeps the text a constant font size: It doesn’t stretch or scale the text to fit the canvas. Use
Core Text to determine the required canvas size for a particular string or layout.

## Relationships

### Conforms To

[`Component`](/documentation/RealityKit/Component)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)