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

# Binding Data

> Binding is how you connect data to properties and elements in your Rive file.

export const UseCase = ({title, children}) => {
  return <aside class="callout my-4 px-5 py-4 overflow-hidden rounded-2xl flex gap-3 border border-neutral-200 bg-neutral-50 dark:border-neutral-700 dark:bg-white/10" data-callout-type="info">
      <div class="mt-0.5 w-4" data-component-part="callout-icon">
        <svg width="11" height="14" viewBox="0 0 11 14" fill="currentColor" xmlns="http://www.w3.org/2000/svg" class="text-neutral-800 dark:text-neutral-300 w-3.5 h-auto" aria-label="Tip"><path d="M3.12794 12.4232C3.12794 12.5954 3.1776 12.7634 3.27244 12.907L3.74114 13.6095C3.88471 13.8248 4.21067 14 4.46964 14H6.15606C6.41415 14 6.74017 13.825 6.88373 13.6095L7.3508 12.9073C7.43114 12.7859 7.49705 12.569 7.49705 12.4232L7.50055 11.3513H3.12521L3.12794 12.4232ZM5.31288 0C2.52414 0.00875889 0.5 2.26889 0.5 4.78826C0.5 6.00188 0.949566 7.10829 1.69119 7.95492C2.14321 8.47011 2.84901 9.54727 3.11919 10.4557C3.12005 10.4625 3.12175 10.4698 3.12261 10.4771H7.50342C7.50427 10.4698 7.50598 10.463 7.50684 10.4557C7.77688 9.54727 8.48281 8.47011 8.93484 7.95492C9.67728 7.13181 10.1258 6.02703 10.1258 4.78826C10.1258 2.15486 7.9709 0.000106649 5.31288 0ZM7.94902 7.11267C7.52078 7.60079 6.99082 8.37878 6.6077 9.18794H4.02051C3.63739 8.37878 3.10743 7.60079 2.67947 7.11294C2.11997 6.47551 1.8126 5.63599 1.8126 4.78826C1.8126 3.09829 3.12794 1.31944 5.28827 1.3126C7.2435 1.3126 8.81315 2.88226 8.81315 4.78826C8.81315 5.63599 8.50688 6.47551 7.94902 7.11267ZM4.87534 2.18767C3.66939 2.18767 2.68767 3.16939 2.68767 4.37534C2.68767 4.61719 2.88336 4.81288 3.12521 4.81288C3.36705 4.81288 3.56274 4.61599 3.56274 4.37534C3.56274 3.6515 4.1515 3.06274 4.87534 3.06274C5.11719 3.06274 5.31288 2.86727 5.31288 2.62548C5.31288 2.38369 5.11599 2.18767 4.87534 2.18767Z"></path></svg>
      </div>
      <div class="text-sm prose dark:prose-invert min-w-0 w-full [&_kbd]:bg-background-light dark:[&_kbd]:bg-background-dark [&_code]:!text-current [&_kbd]:!text-current [&_a]:!text-current [&_a]:border-current [&_strong]:!text-current text-neutral-800 dark:text-neutral-300" data-component-part="callout-content">
        <strong>Example{title && ` - ${title}`}</strong>

        {children}
      </div>
    </aside>;
};

export const YouTube = ({id, timestamp}) => {
  const videoSrc = timestamp ? `https://www.youtube.com/embed/${id}?start=${timestamp}` : `https://www.youtube.com/embed/${id}`;
  return <iframe width="100%" height="400" src={videoSrc} title="YouTube video player" frameBorder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerPolicy="strict-origin-when-cross-origin" allowFullScreen />;
};

For example, if you have a `teamName` property bound to a text run in your scene, changing the `teamName` value updates the displayed text automatically.

You can change property values in the editor or at runtime, allowing you to create dynamic experiences that adapt to each user.

Bindings are not limited to visual properties. You can bind values throughout your file, including transforms, animation speeds, [converter values](/editor/data-binding/converters#converter-types), [script inputs](/scripting/script-inputs#data-binding-inputs), [transition condition values](/editor/state-machine/transitions), and more.

This allows the same data to drive behavior, animation, and logic across your scene, helping keep everything in sync.

## Binding a Property

Let's control the `X` position of a circle using `circleX`, which is a Number property in our View Model.

<img src="https://mintcdn.com/rive-transitions-2/pUWAhxU9qubdBvIR/images/editor/data-binding/binding-data/bind-value.gif?s=62ab2fddbedfe867c9f765b91f6db7de" alt="Bind a property" width="640" height="340" data-path="images/editor/data-binding/binding-data/bind-value.gif" />

<Steps>
  <Step title="Bind the property">
    With your circle selected, right-click the `X` field, and select **Data Bind**.
  </Step>

  <Step title="Select the property">
    In the **Property** dropdown, select `circleX`.
  </Step>
</Steps>

The `X` field should now be highlighted in green, indicating that it's bound to a value.

The circle's horizontal position is now driven by the `circleX` property. Any time the property's value changes, the circle updates automatically.

<img src="https://mintcdn.com/rive-transitions-2/pUWAhxU9qubdBvIR/images/editor/data-binding/binding-data/updating-values.gif?s=75891588c6e23875d62d998266ee4eb7" alt="Bind a property" width="640" height="222" data-path="images/editor/data-binding/binding-data/updating-values.gif" />

<Warning>
  If the field has a yellow border, there is a problem with the binding.

  In most cases, the property type is incompatible with the target value. For example, the `X` position of an element can only be bound to a Number property.
</Warning>

<Tip>
  **Previewing Bindings**

  By default, your data only controls your elements when the state machine is playing.

  To preview your data-bound values, turn on the **Data Binding Preview Toggle**.

  <img src="https://mintcdn.com/rive-transitions-2/pUWAhxU9qubdBvIR/images/editor/data-binding/binding-data/preview-data-binding.gif?s=4d11af70619e9aef45d10a2ce48cbec9" alt="Preview data binding" width="640" height="235" data-path="images/editor/data-binding/binding-data/preview-data-binding.gif" />
</Tip>

### Updating a Binding

Right-click the bound element and select **Update Bind**.

<img src="https://mintcdn.com/rive-transitions-2/pUWAhxU9qubdBvIR/images/editor/data-binding/binding-data/update-bind.gif?s=5f4778cbc56bf8656c6c7403219f7d60" alt="Update a binding" width="640" height="389" data-path="images/editor/data-binding/binding-data/update-bind.gif" />

### Removing a Binding

Right-click the bound element and select **Unbind**.

<img src="https://mintcdn.com/rive-transitions-2/pUWAhxU9qubdBvIR/images/editor/data-binding/binding-data/unbind.gif?s=65c3c1eb2b34eaa6265cf0f845768cc4" alt="Remove a binding" width="640" height="332" data-path="images/editor/data-binding/binding-data/unbind.gif" />

## Binding Options

Each binding has the following properties.

### Property

The View Model property the target is connected to.

<img src="https://mintcdn.com/rive-transitions-2/pUWAhxU9qubdBvIR/images/editor/data-binding/binding-data/property.png?fit=max&auto=format&n=pUWAhxU9qubdBvIR&q=85&s=06bf723a4a820046d7415f29aec640f7" alt="Property field" width="1308" height="308" data-path="images/editor/data-binding/binding-data/property.png" />

### Path

When binding to nested View Models, there may be multiple properties with the same name available.

The path determines which specific property instance the binding should use.

<img src="https://mintcdn.com/rive-transitions-2/pUWAhxU9qubdBvIR/images/editor/data-binding/binding-data/path.gif?s=7c09c068442a0ccf7f5148d2b38fbf38" alt="Preview data binding" width="640" height="269" data-path="images/editor/data-binding/binding-data/path.gif" />

See also [Absolute vs Relative Binding](#absolute-vs-relative-binding).

### Bind Direction

By default, the View Model property (**source**) controls the bound element or value (**target**), but it can also work the other way around.

<YouTube id="Syt6i4-Bkm4" />

#### Target to Source

When a binding has `Target to Source` toggled on, a change to the element will update the view model property.

<img src="https://mintcdn.com/rive-transitions-2/pUWAhxU9qubdBvIR/images/editor/data-binding/binding-data/target-to-source.png?fit=max&auto=format&n=pUWAhxU9qubdBvIR&q=85&s=9cf8043de3c3af8ae02dad077f681940" alt="Target to source" width="1308" height="308" data-path="images/editor/data-binding/binding-data/target-to-source.png" />

<UseCase title="Tracking Positions">
  Let's say you have a walk cycle animation and you want to track the exact Y position of the head as it bobs up and down.

  With the head's `Y` position bound to `headY` using **Target to Source**, the `headY` property updates automatically as the head moves.
</UseCase>

#### Bidirectional

A change to the view model property will update the element **AND** a change to the element will update the view model property.

<img src="https://mintcdn.com/rive-transitions-2/pUWAhxU9qubdBvIR/images/editor/data-binding/binding-data/bidirectional.gif?s=ca69c91622a5176af3d72e69c8ce8ac3" alt="Bidirectional data binding" width="640" height="211" data-path="images/editor/data-binding/binding-data/bidirectional.gif" />

Clicking the **Bidirectional** toggle multiple times will cycle between **Bidirectional (prefer target value)** and **Bidirectional (prefer source value)**.

In rare cases, both the source and target may change at the same time. This setting determines which value wins when a conflict occurs.

<UseCase title="Checkers">
  Let's say you're building a game of checkers and need to create logic for dragging and dropping each piece.

  The initial position of each piece is determined by the `piecePositionX` and `piecePositionY` properties (source to target).

  As the piece is dragged, the piece itself (target) updates those property values (target to source).
</UseCase>

### Bind Once

When **Bind Once** is enabled, the binding only applies the value a single time when the scene starts or the binding is created.

<img src="https://mintcdn.com/rive-transitions-2/pUWAhxU9qubdBvIR/images/editor/data-binding/binding-data/bind-once.png?fit=max&auto=format&n=pUWAhxU9qubdBvIR&q=85&s=032e1ca47e7fe6375c44aaee788fb29d" alt="Bind once" width="1308" height="308" data-path="images/editor/data-binding/binding-data/bind-once.png" />

After the initial value is applied, future changes to the source or target are ignored.

<UseCase>
  Let's say you're creating a particle effect and want each particle to start with a random rotation value.

  You could bind the particle's rotation to a random number property using **Bind Once**. Each particle would receive its initial rotation value, but future changes to the property would not affect existing particles.
</UseCase>

### Absolute vs Relative Binding

<YouTube id="4LOXhXesG74" />

By default, new data binding connections are created as absolute binds.

* **Absolute Binding**: The binding points to a specific property instance within the View Model hierarchy.
* **Relative Binding**: The binding searches for a property with a matching name relative to the current context.
