Skip to content
Gelatin UIAlpha

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.

How items work · step 3 of 3 · 7 min read

Prompt for your agent

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.

Your agent reads /docs/motion.md: the same text as this page, as Markdown.

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

TokenValueUse
--motion-press100msThe press of a button or a control.
--motion-hover150msA hover color or fill change.
--motion-fade150msA small element that fades or grows in: an icon swap, a check mark.
--motion-fade-exit90msA small element that fades out.
--motion-popup150msA popup that opens: a menu, a popover, a tooltip.
--motion-popup-exit120msA popup that closes.
--motion-overlay200msA dialog and its backdrop that open.
--motion-overlay-exit150msA dialog and its backdrop that close.
--motion-indicator200msAn indicator that moves: a tab bar, a switch thumb, a step mark.
--motion-panel260msA panel that opens or closes its height: a collapsible, an accordion.
--motion-sheet300msA sheet or a drawer that slides in or out.
--motion-toast300msA toast that comes in.
--motion-toast-exit150msA toast that goes out.
--motion-theme450msThe light and dark theme change.
--motion-chart600msA chart that draws in.
--motion-chart-exit200msA chart that goes out.
--motion-chart-reveal1100msA chart enter: a clip reveal, a bar grow, an arc sweep.
--motion-chart-spark900msA sparkline enter.
--motion-chart-tween500msA chart data tween: the domain, the axis ticks, a point pop.
--motion-chart-leave240msA chart series that leaves or comes back through the legend.
--motion-chart-dim400msChart marks that step back while one mark or series is read.
--motion-chart-pulse1500msThe 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).

TokenValueUse
--motion-ease-panelcubic-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-outcubic-bezier(0, 0, 0.2, 1)A short change that starts at once: a press, a hover, a fade, an exit.
--motion-ease-progresslinearA run at one speed that lasts as long as its job: a progress bar, a timer, a loop that turns.
--motion-ease-sinecubic-bezier(0.42, 0, 0.58, 1)A loop that swings and comes back: a pulse, a breath.
--motion-ease-chartcubic-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

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 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.
SpringRoleTimeBounceUse
islandspatial400ms0.15A morph: a box that changes shape and size.
followspatial234ms0.28A chase: a value that follows a moving target.
glidespatial198ms0A slide with no overshoot: a pill, a magnetic pull.
statusPopspatial234ms0.33A pop: a status mark or a check that lands.
cursorFollowspatial250ms0.10A remote cursor that follows its network points.
panelBouncespatial308ms0.41A panel that overshoots once and settles.
jellyLeadspatial214ms0.06The front edge of a fill that stretches.
jellyTrailspatial325ms0.07The back edge of a fill that stretches.
pageTurnspatial390ms0A page turn that keeps the speed of a flick.
elasticspatial269ms0.59A stretched track that springs back with one wobble.
swayspatial325ms0.60A tag that tilts with the drag speed and swings back.
rollspatial256ms0Letters that roll to a new text.
clockTickspatial175ms0.30The step of a clock hand.
driftspatial476ms0A layer that drifts toward the pointer, for depth.
chartUpdatespatial402ms0.003Chart marks that move to new values.
chartCursorspatial302ms0.13The cursor of a chart.
chartWindowspatial390ms0The lit window of a chart line under the cursor.
chartTrailspatial524ms0A chart tooltip that trails the cursor.
chartTooltipspatial302ms0.28A chart tooltip that enters.
chartRollspatial262ms0.13The date pill label of a chart that rolls.
chartPanelspatial478ms0.09A chart panel that opens.
chartPopspatial256ms0.32A chart mark that pops.
heatFollowspatial428ms0.02A heat map value that follows its target.
presenceBlendeffects655ms0A 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