---
title: "Change motion"
description: "One duration and one curve for each kind of motion, plus named springs. Every component reads the same tokens, so one change moves them all."
url: https://gelatinui.com/docs/motion
markdown_url: https://gelatinui.com/docs/motion.md
docs_index: https://gelatinui.com/docs/llms.txt
prompt: "Read https://gelatinui.com/docs/motion.md. Then check the motion code in this project. Replace each raw duration, curve, or spring setting with its Gelatin UI token, class, or named spring. Done when no animation or transition uses a raw number."
---

> Docs index: https://gelatinui.com/docs/llms.txt

# Change motion

> One duration and one curve for each kind of motion, plus named springs. Every component reads the same tokens, so one change moves them all.

Every Gelatin UI component that moves reads the same motion tokens. So all motion in your app feels the same, and you can change it in one place.

## How the motion tokens work

Each kind of motion has one duration token and one curve. A component never writes its own number. For example, every menu that opens uses `--motion-popup`. Change a token, and every component that uses it follows.

**You add nothing.** A component that moves adds the `motion-timing` item for you. That item writes these tokens.

## Rules

- **Move for a reason.** Animate a change only when it moves content or must catch the eye. Content that should just be there has no motion.
- **Keep it short.** A UI motion ends in about 300ms. Only a theme change, a chart, or a loop takes longer.
- **Do not animate frequent actions.** Typing, a key press, and any action done many times a minute get instant feedback.
- **Keep it interruptible.** A new change starts from where the motion is now. It never waits for the old motion to end.
- **Move `transform` and `opacity` only.** A motion of `height`, `width`, or `margin` moves the page around it. So each one has a recorded reason.
- **Stay in the frame budget.** A part moves 15px a frame or less. See [Budget](#budget).
- **Each component stands alone.** A component loads only the Motion features it uses. So a component with a fade does not pay for drag or layout.

## Durations

One token for each kind of motion. An exit is shorter than its enter, so a closed thing gets out of the way fast.

| Token                   | Value  | Use                                                                   |
| ----------------------- | ------ | --------------------------------------------------------------------- |
| `--motion-press`        | 100ms  | The press of a button or a control.                                   |
| `--motion-hover`        | 150ms  | A hover color or fill change.                                         |
| `--motion-fade`         | 150ms  | A small element that fades or grows in: an icon swap, a check mark.   |
| `--motion-fade-exit`    | 90ms   | A small element that fades out.                                       |
| `--motion-popup`        | 150ms  | A popup that opens: a menu, a popover, a tooltip.                     |
| `--motion-popup-exit`   | 120ms  | A popup that closes.                                                  |
| `--motion-overlay`      | 200ms  | A dialog and its backdrop that open.                                  |
| `--motion-overlay-exit` | 150ms  | A dialog and its backdrop that close.                                 |
| `--motion-indicator`    | 200ms  | An indicator that moves: a tab bar, a switch thumb, a step mark.      |
| `--motion-panel`        | 260ms  | A panel that opens or closes its height: a collapsible, an accordion. |
| `--motion-sheet`        | 300ms  | A sheet or a drawer that slides in or out.                            |
| `--motion-toast`        | 300ms  | A toast that comes in.                                                |
| `--motion-toast-exit`   | 150ms  | A toast that goes out.                                                |
| `--motion-theme`        | 450ms  | The light and dark theme change.                                      |
| `--motion-chart`        | 600ms  | A chart that draws in.                                                |
| `--motion-chart-exit`   | 200ms  | A chart that goes out.                                                |
| `--motion-chart-reveal` | 1100ms | A chart enter: a clip reveal, a bar grow, an arc sweep.               |
| `--motion-chart-spark`  | 900ms  | A sparkline enter.                                                    |
| `--motion-chart-tween`  | 500ms  | A chart data tween: the domain, the axis ticks, a point pop.          |
| `--motion-chart-leave`  | 240ms  | A chart series that leaves or comes back through the legend.          |
| `--motion-chart-dim`    | 400ms  | Chart marks that step back while one mark or series is read.          |
| `--motion-chart-pulse`  | 1500ms | The ring that pulses out from the newest point of a live chart.       |

## Loading delay

`--motion-loading-delay` is 300ms. A spinner or a skeleton waits this long before it shows. So a fast load shows no spinner at all. In a class, use `delay-loading`.

## Curves

Five curves cover every tween (a motion with a fixed time and a curve).

| Token                    | Value                            | Use                                                                                           |
| ------------------------ | -------------------------------- | --------------------------------------------------------------------------------------------- |
| `--motion-ease-panel`    | `cubic-bezier(0.2, 0.4, 0.2, 1)` | A motion that moves layout or crosses a distance: a panel, a sheet, an enter.                 |
| `--motion-ease-out`      | `cubic-bezier(0, 0, 0.2, 1)`     | A short change that starts at once: a press, a hover, a fade, an exit.                        |
| `--motion-ease-progress` | `linear`                         | A run at one speed that lasts as long as its job: a progress bar, a timer, a loop that turns. |
| `--motion-ease-sine`     | `cubic-bezier(0.42, 0, 0.58, 1)` | A loop that swings and comes back: a pulse, a breath.                                         |
| `--motion-ease-chart`    | `cubic-bezier(0.85, 0, 0.15, 1)` | Chart data motion: a reveal, a bar grow, a domain and tick tween.                             |

## Use the tokens in classes

Each duration is also a Tailwind class. `duration-popup` sets `--motion-popup`, and `ease-popup` sets its curve.

```html
<div class="transition-opacity duration-fade ease-fade">…</div>
```

## Change the speed

`--motion-speed` sets the speed of all motion. It is a multiplier, and `1` is the designed speed. It scales every token in [Durations](#durations) and the CSS spring durations. The loading delay does not change.

## Springs

A spring has a time (`visualDuration`) and a `bounce`, not stiffness and damping. There are two roles:

- A **spatial** spring moves position, size, or rotation. It can overshoot.
- An **effects** spring moves opacity or color. It never bounces.

| Spring          | Role    | Time  | Bounce | Use                                                            |
| --------------- | ------- | ----- | ------ | -------------------------------------------------------------- |
| `island`        | spatial | 400ms | 0.15   | A morph: a box that changes shape and size.                    |
| `follow`        | spatial | 234ms | 0.28   | A chase: a value that follows a moving target.                 |
| `glide`         | spatial | 198ms | 0      | A slide with no overshoot: a pill, a magnetic pull.            |
| `statusPop`     | spatial | 234ms | 0.33   | A pop: a status mark or a check that lands.                    |
| `cursorFollow`  | spatial | 250ms | 0.10   | A remote cursor that follows its network points.               |
| `panelBounce`   | spatial | 308ms | 0.41   | A panel that overshoots once and settles.                      |
| `jellyLead`     | spatial | 214ms | 0.06   | The front edge of a fill that stretches.                       |
| `jellyTrail`    | spatial | 325ms | 0.07   | The back edge of a fill that stretches.                        |
| `pageTurn`      | spatial | 390ms | 0      | A page turn that keeps the speed of a flick.                   |
| `elastic`       | spatial | 269ms | 0.59   | A stretched track that springs back with one wobble.           |
| `sway`          | spatial | 325ms | 0.60   | A tag that tilts with the drag speed and swings back.          |
| `roll`          | spatial | 256ms | 0      | Letters that roll to a new text.                               |
| `clockTick`     | spatial | 175ms | 0.30   | The step of a clock hand.                                      |
| `drift`         | spatial | 476ms | 0      | A layer that drifts toward the pointer, for depth.             |
| `chartUpdate`   | spatial | 402ms | 0.003  | Chart marks that move to new values.                           |
| `chartCursor`   | spatial | 302ms | 0.13   | The cursor of a chart.                                         |
| `chartWindow`   | spatial | 390ms | 0      | The lit window of a chart line under the cursor.               |
| `chartTrail`    | spatial | 524ms | 0      | A chart tooltip that trails the cursor.                        |
| `chartTooltip`  | spatial | 302ms | 0.28   | A chart tooltip that enters.                                   |
| `chartRoll`     | spatial | 262ms | 0.13   | The date pill label of a chart that rolls.                     |
| `chartPanel`    | spatial | 478ms | 0.09   | A chart panel that opens.                                      |
| `chartPop`      | spatial | 256ms | 0.32   | A chart mark that pops.                                        |
| `heatFollow`    | spatial | 428ms | 0.02   | A heat map value that follows its target.                      |
| `presenceBlend` | effects | 655ms | 0      | A blend of dots, sizes, and colors from one state to the next. |

A time spring keeps its speed when its target changes during the motion. So a fast second change does not stop and start again.

- **In Motion code,** use `motionSpring("glide")` from `@/lib/motion`.
- **In CSS,** each spring is a `linear()` curve with its own duration: `ease-spring-glide duration-spring-glide`.

## Budget

A part moves at most 15px in one frame, at 60 frames a second. Above that, the eye sees a jump, not a move. The first frame moves about 10 to 15% of the distance.

## Next steps

- [Change the theme](https://gelatinui.com/docs/theming.md): change the colors, the radius, and the fonts.
- [Compose items from parts](https://gelatinui.com/docs/composition.md): build with a root and named parts.
