---
title: "Make a button react to a press"
description: "Make a button wait in idle, play one pulse when pressed, and return to idle."
canonical: "https://terminal.lottiefiles.com/docs/how-to/make-a-button-react-to-a-press/"
last_updated: 2026-10-29
---

# Make a button react to a press

Make a button wait in idle, play one pulse when pressed, and return to idle.

Start with a layer named `button` and two markers on the score (the timeline): `idle` for
the resting pose and `pulse` for one complete movement. The **State machines** lesson uses
this arrangement. Use a file copy so you can add states.

1. Press `⌃T`. The state graph opens beside the stage.
2. Click **+ a state for each marker**. Cards named **idle** and **pulse** appear, with an
   incoming arrow on **idle**.
3. Click the **idle** card. Its settings and rules appear in the inspector.
4. Click **+ rule**. A line opens for typing.
5. Type `press button → pulse` and press `⏎`. An arrow connects **idle** to **pulse**.
6. Click the **pulse** card. Its inspector shows **plays pulse**.
7. Click **⟳ loop** only if it is lit, to turn it off. The pulse must finish for `ends` to fire.
8. Press `⏎`. A new rule line opens under **pulse**.
9. Type `ends → idle` and press `⏎`. An arrow returns from **pulse** to **idle**.
10. Press `space`. The stage becomes the player and waits in **idle**.
11. Click the button on the stage. It pulses; **WHAT HAPPENED** records the press and the
    return to **idle** when the stretch ends.

![Two states connected by press button and ends rules, with pulse's settings beside the graph.](https://terminal.lottiefiles.com/docs/assets/shots/more-state-button-rules.png)

Press `esc` to stop trying it. Save or export a `.lottie` for a player with state-machine
support; JSON alone does not make an ordinary Lottie player interactive.
Next: [Inputs, rules and blends](https://terminal.lottiefiles.com/docs/states.md).
Watch: [State machines](https://terminal.lottiefiles.com/state-machines/).
