> ## Documentation Index
> Fetch the complete documentation index at: https://rive.app/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Text

> ⚠️ DEPRECATED: Use Data Binding instead of direct text run manipulation at runtime

export const Apple = {
  currentRuntimeName: "New Runtime",
  legacyRuntimeName: "Legacy Runtime"
};

<Warning>
  This deprecated feature is only supported in the Legacy Runtime, not the {Apple.currentRuntimeName}.
</Warning>

<Warning>
  **DEPRECATION NOTICE:** This entire page documents the legacy Text
  manipulation system. **For new projects:** Use <Link href="data-binding">Data Binding</Link> instead. **For existing projects:** Plan to
  migrate from direct text run manipulation to Data Binding as soon as possible.
</Warning>

For more information on designing and animating Text, please refer to the editor's text section:

<CardGroup cols={2}>
  <Card
    title="Text"
    href="/editor/text/text-overview"
    icon={
  <svg
    xmlns="http://www.w3.org/2000/svg"
    height="100%"
    fill="none"
    viewBox="0 0 16 16"
    className="size-4 text-gray-500/80 dark:text-gray-400"
    aria-hidden="true"
  >
    <path
      fill="currentColor"
      d="M7.31 7.111 2.406 5.15l4.61-1.844.328-.126a2.3 2.3 0 0 1 1.647 0l.33.126L13.93 5.15 9.024 7.112c-.55.22-1.163.22-1.712 0"
    ></path>
    <path
      stroke="currentColor"
      stroke-linecap="round"
      stroke-linejoin="round"
      d="m2.405 10.911 4.906 1.963c.55.22 1.162.22 1.712 0l4.906-1.963M2.405 8.031 7.31 9.992c.55.22 1.162.22 1.712 0l4.906-1.963M2.405 5.15 7.31 7.111c.55.22 1.162.22 1.712 0l4.906-1.962-4.61-1.844-.329-.126a2.3 2.3 0 0 0-1.647 0l-.329.126z"
    ></path>
  </svg>
}
  >
    Information on designing and animating Text
  </Card>
</CardGroup>

## Read/Update Text Runs at Runtime

<Warning>
  **⚠️ LEGACY CONTENT WARNING:** The following sections document the deprecated
  Text manipulation system. **This content is provided for legacy support
  only.** New implementations should use <Link href="data-binding">Data Binding</Link>.
</Warning>

If you intend to update a **text run** at runtime it's important to manually enter a *unique name* for the run in the editor:

<img src="https://mintcdn.com/rive/QEBBdwwFJOiq_hKR/images/runtimes/3114789e-e298-458e-8d9b-00ca71db658d.webp?fit=max&auto=format&n=QEBBdwwFJOiq_hKR&q=85&s=016fd8859f1b8906aa175d6edd0b6b65" alt="Image" width="578" height="298" data-path="images/runtimes/3114789e-e298-458e-8d9b-00ca71db658d.webp" />

And then export the name: **right-click** and select **Export name**

<img src="https://mintcdn.com/rive/QEBBdwwFJOiq_hKR/images/runtimes/b729291c-f915-4ce0-b2fa-f6d6a742141c.webp?fit=max&auto=format&n=QEBBdwwFJOiq_hKR&q=85&s=7b3b4b6b6370896ef96b01f5d9c2861e" alt="Image" width="391" height="481" data-path="images/runtimes/b729291c-f915-4ce0-b2fa-f6d6a742141c.webp" />

You can identify an exported component if it's surrounded by square brackets. This makes it possible for the run to be "discoverable" at runtime by its name. For more information, see [Exporting for Runtime](/editor/exporting/exporting-for-runtime).

<Warning>
  **If the name is not set manually in the editor the name will not be part of
  the exported *.riv* (to reduce file size).**
</Warning>

<Note>
  Text runs can also be updated on components at runtime, see [Read/Update
  Nested Text Runs at Runtime](#read-update-nested-text-runs-at-runtime) below.
</Note>

#### Reading Text

To read a given text run text value at any given time, reference the `.getTextRunValue()` API on the `RiveViewModel`:

```swift theme={null}
open func getTextRunValue(_ textRunName: String) -> String?
```

Supply the text run name and you'll have the Rive text run value returned, or `nil` if the text run could not be queried.

#### Setting Text

To set a given text run value at any given time, reference the `.setTextRunValue()` API on the `RiveViewModel`:

```swift theme={null}
open func setTextRunValue(_ textRunName: String, textValue: String) throws
```

Supply the text run name and a second parameter, `textValue`, with a String value that you want to set the new text value for.

<Note>
  If the supplied `textRunName` Rive text run cannot be queried on the active artboard, Rive will throw a `RiveError.textValueRunError` that you may need to catch and handle gracefully in your application.
</Note>

#### Example Usage

```swift theme={null}
@State private var userInput: String = ""
@State private var rvm = RiveViewModel(fileName: "my-rive-file")

var body: some View {
    VStack(spacing: 20) {
        Text("Enter text:")
            .font(.headline)
        TextField("Enter text...", text: $userInput)
            .textFieldStyle(RoundedBorderTextFieldStyle())
            .padding()
            .onChange(of: userInput, perform: { newValue in
                if (!newValue.isEmpty) {
                    try! rvm.setTextRunValue("MyTextRunName", textValue: userInput)
                }
            })
        rvm.view()
    }
}
```

## Read/Update Nested Text Runs at Runtime

<Warning>
  **⚠️ DEPRECATED FEATURE:** Nested Text Runs are part of the legacy Text
  manipulation system. **Use Data Binding instead** for controlling component
  text properties at runtime.
</Warning>

It's possible to set nested text runs at runtime—text that is not on the main artboard but on a [Component](/editor/fundamentals/components). To set a nested text run, you'll need to take note of the path where the input exists at an artboard level.

For example, to get/set the text run named **button\_text** on the **Button** artboard, you need to provide the correct path.

<img src="https://mintcdn.com/rive/QEBBdwwFJOiq_hKR/images/runtimes/51848b07-5a82-4fc9-ab3f-0505336fcce3.webp?fit=max&auto=format&n=QEBBdwwFJOiq_hKR&q=85&s=c8ce539dc6a4608a1a9306d84d22d46a" alt="Setting Nested Text Runs " width="3022" height="1546" data-path="images/runtimes/51848b07-5a82-4fc9-ab3f-0505336fcce3.webp" />

*Setting Nested Text Runs*

The artboard names here are:

* **Main** -> **NestedArtboard** -> **Button**

<img src="https://mintcdn.com/rive/QEBBdwwFJOiq_hKR/images/runtimes/fc5b5be2-546f-44d0-ad85-f7a8da64973b.webp?fit=max&auto=format&n=QEBBdwwFJOiq_hKR&q=85&s=cd27346bb83269fef885a9f8979e3953" alt="Image" width="1580" height="1082" data-path="images/runtimes/fc5b5be2-546f-44d0-ad85-f7a8da64973b.webp" />

However, the path is determined based on the names set in the hierarchy:

* **ArtboardWithUniqueName** -> **ButtonWithUniqueName**

The path is then: `ArtboardWithUniqueName/ButtonWithUniqueName`

<Warning>
  Be sure to mark the components and text runs as exported.

  <br />

  <img src="https://mintcdn.com/rive/QEBBdwwFJOiq_hKR/images/runtimes/618066cd-2909-420e-b94b-d3eb920fe389.webp?fit=max&auto=format&n=QEBBdwwFJOiq_hKR&q=85&s=56cb1192d2293554f855737775f6b2e9" alt="Export component
  name" width="1892" height="1010" data-path="images/runtimes/618066cd-2909-420e-b94b-d3eb920fe389.webp" /> *Export
  component name*
</Warning>

<Warning>
  Do not use "/" in the name for your components, as that will break the search
  functionality at runtime.
</Warning>

### Reading Text

Similar to [reading text from a text run within a parent artboard](#reading-text), you can set the value of a text run within a component instance using the following API:

```swift theme={null}
open func getTextRunValue(_ textRunName: String, path: String) -> String?
```

### Setting Text

Additionally, similar to [setting text within a parent artboard](#setting-text), you can read the value of a text run within a component instance using the following API:

```swift theme={null}
open func setTextRunValue(_ textRunName: String, textValue: String, path: String) throws
```

### Example:

```swift theme={null}
@State private var userInput: String = ""
@State private var rvm = RiveViewModel(fileName: "my-rive-file")

var body: some View {
    VStack(spacing: 20) {
        Text("Enter text:")
            .font(.headline)
        TextField("Enter text...", text: $userInput)
            .textFieldStyle(RoundedBorderTextFieldStyle())
            .padding()
            .onChange(of: userInput, perform: { newValue in
                if (!newValue.isEmpty) {
                    try! rvm.setTextRunValue("MyTextRunName", textValue: userInput, path: "Artboard/NestedArtboard")
                }
            })
        rvm.view()
    }
}
```

### Semantics for Accessibility

Rive now supports screen readers through semantics.

See the [Semantics](/editor/accessibility/semantics) documentation for current guidance.
