> ## 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.

# Actions

> Set view model properties, report events, move focus, and more when a state starts or ends, a transition happens, or a listener fires.

An action does something in response to the state machine, such as setting a view model property or reporting an event. Actions can run from three places:

* **[States](https://rive.app/docs/editor/state-machine/states.md)**: when the state starts or ends.
* **[Transitions](https://rive.app/docs/editor/state-machine/transitions.md)**: when the transition starts or ends.
* **[Listeners](https://rive.app/docs/editor/state-machine/listeners.md)**: when the listener fires.

The same action types are available in all three. You can add as many actions as you need, and you can [data bind](https://rive.app/docs/editor/data-binding/overview.md) the values they use.

[YouTube video player](https://www.youtube.com/embed/4Uuu0MkBawE)

## Action types

| Action | What it does |
| - | - |
| **View Model Change** | Sets a [view model](https://rive.app/docs/editor/data-binding/overview.md) property. |
| **Input Change** | Sets a legacy state machine [input](https://rive.app/docs/editor/state-machine/inputs). Use View Model Change for new work. |
| **Align Target** | Moves an object to the pointer. See [Align Target](#align-target). |
| **Focus** | Moves keyboard [focus](https://rive.app/docs/editor/accessibility/focus.md). See [Focus](#focus). |
| **Report Event** | Fires a [Rive event](https://rive.app/docs/editor/events/overview.md). |
| **Scripted Action** | Runs a [listener action script](https://rive.app/docs/scripting/protocols/listener-action-scripts.md). |

### Align Target

Moves the target object to the pointer's position. Use it to make an object follow the pointer, such as a custom cursor or a slider handle.

* **Target**: The object to move.
* **Preserve offset**: Keeps the object's distance from the pointer when the action starts, instead of snapping its origin to the pointer.

### Focus

Moves [focus](https://rive.app/docs/editor/accessibility/focus.md) between focusable elements. Choose a mode:

* **target**: Focuses a specific element.
* **traverse**: Moves focus in a direction: **next**, **previous**, **up**, **down**, **left**, or **right**.
* **clear**: Removes focus.

## Adding an action to a state or transition

**Step 1**

Select the state or transition in the graph.

**Step 2**

In the panel below the graph, click **+** next to its name and choose an action type.

**Step 3**

Choose when the action runs: at **enter** or at **exit**.

* For a state, **enter** runs when the state starts and **exit** runs when the layer leaves it.
* For a transition, **enter** runs when the transition starts and **exit** runs when it finishes.

**Step 4**

Configure the action.

![Adding an action to a state](https://mintcdn.com/rive/hgtDuQKKVCQlJ56m/images/editor/state-machine/transitions/state-action.gif?s=bd5d42389aa4cbb2d33925a5b0ee8d5b)

## Adding an action to a listener

**Step 1**

Select the listener in the **Listeners** panel.

**Step 2**

In the panel below the graph, click **+** and choose an action type.

**Step 3**

Configure the action.

Listener actions run every time the listener fires.

<video src="https://static.rive.app/video/docs/add-action-to-listener.mp4" autoPlay loop muted playsInline />
