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

# Examples

> Sample projects, headless rendering, and running the CLI in CI.

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>;
};

## Sample projects

The CLI ships eight example projects. `rive samples` opens a picker and copies the
one you choose into a directory you name:

| Sample             | Shows                                                                                      |
| ------------------ | ------------------------------------------------------------------------------------------ |
| `hello_rive`       | The smallest layout script: draw a moving shape each frame                                 |
| `rml_triangle`     | The smallest RML document: one artboard, one shape                                         |
| `rml_vm_input`     | RML driven by view model data, with a script input                                         |
| `rml_split`        | The same scene split across files: view models in `data/`, referenced by id from the scene |
| `pointer_reactive` | Making a scene follow the mouse: pointer to view model to data bind                        |
| `input_demo`       | Keyboard, text and gamepad events in a script                                              |
| `text_input`       | Editable text fields with the TextInput component                                          |
| `tests_demo`       | Luau unit tests, run with `--test`                                                         |

Each directory is a project in its own right. Where no picker can draw, as in CI,
`rive samples` prints the list with descriptions and a ready `cp` line:

```bash theme={null}
cp -R "$(rive samples --path)/rml_triangle" myproject
rive myproject
```

## Headless rendering

`--screenshot` builds the project, renders one frame without opening a window, and
writes a PNG. It needs no login, which makes it the check to run in CI.

```bash theme={null}
rive myproject --screenshot=out.png                    # before anything advances
rive myproject --screenshot=out.png --advance=1s       # one second in
rive myproject --screenshot=out.png --viewport=390x844 # at a specific size
```

<Note>
  A capture with no `--advance` is the authored rest pose, not the animation's opening
  frame, because the state machine has not run yet. Start previews at `--advance=1`.
</Note>

<Note>
  `--screenshot` resolves its path against the current directory, not the project
  directory, and a missing directory fails with only `screenshot failed: <path>`.
  Create the directory first.
</Note>

## Driving a scene

A screenshot of a resting scene tells you nothing about whether it responds to
anything. Two flags drive it before the capture.

`--data` sets a view model property. The path is relative to the instance bound to
the artboard, and each segment is a property name:

```bash theme={null}
rive myproject --screenshot=full.png --data=battery/level=100
```

`--pointer` simulates a pointer at artboard coordinates. `click` is a move, a press
and a release with a frame between each, because a state machine only sees a gesture
when it next runs:

```bash theme={null}
rive myproject --screenshot=hover.png --pointer=move@120,60
rive myproject --screenshot=on.png    --pointer=click@120,60 --advance=20
```

Both flags repeat, so you can set several values or play a sequence of gestures.

<Note>
  Quote a `drag` value. The `>` between the two points is a shell redirection
  otherwise:

  ```bash theme={null}
  rive myproject --screenshot=scrolled.png --pointer='drag@200,300>200,80:12'
  ```
</Note>

<UseCase title="Proving a Toggle Works">
  Capture the control at rest, after one click, and after two. `rest` and `on` must
  differ, or the control does nothing. `off` must match `rest`, or it only works one
  way.

  ```bash theme={null}
  rive myproject --screenshot=rest.png
  rive myproject --screenshot=on.png  --pointer=click@120,60 --advance=20
  rive myproject --screenshot=off.png --pointer=click@120,60 --advance=1 \
                                      --pointer=click@120,60 --advance=20
  ```

  Put an `--advance` between two clicks on the same control, as above. A value a
  listener writes is not visible to the next listener until a frame has passed, so
  back-to-back clicks can both act on the old value.
</UseCase>

## Checking responsiveness

A layout tree and a hand-positioned screen look identical in a single screenshot.
Shoot the same file at two sizes and see whether anything moved:

```bash theme={null}
rive myproject --screenshot=wide.png   --viewport=900x600
rive myproject --screenshot=narrow.png --viewport=320x700
```

`--viewport` resizes the artboard itself, rather than scaling or cropping what it
renders. Layouts reflow into the new size, which is what makes this a real
responsiveness check. Content at fixed coordinates stays where it is, so a design
with no layout components looks cropped at a smaller viewport and gains empty space
at a larger one.

## In CI

`--verify` compiles everything and writes nothing. `--test` runs the project's Luau
tests. Both exit non-zero on failure, and `--format=json` gives you one JSON object
on stdout with logs kept on stderr:

```bash theme={null}
rive myproject --verify --format=json
rive myproject --test --format=json
```

Each kind of failure has its own exit code, so a pipeline can branch without parsing
output. See [Exit Codes](/docs/cli/reference/commands#exit-codes).

<Note>
  Publishing needs a browser sign-in, which a CI runner usually cannot do. Every other
  mode works there. You can author, compile, test and capture in CI, then publish from
  a machine that is signed in.
</Note>

## Measuring performance

`--bench` builds the project, times a number of frames without opening a window, and
reports advance and render statistics along with WASM memory growth:

```bash theme={null}
rive myproject --bench=600
```
