Movement
Movement helps to notice the result of an action and the connection between interface states. First, determine what you want the user to understand from the transition, then choose its duration and shape.
When transition helps
Useful animations show the origin of a panel, the change of the selected item, or the completion of an action. It must have a clear reason and not delay the work.
| Problem | What to show | Example Component |
|---|---|---|
| Changing the selected value | Relationship between old and new positions | Segmented |
| Explanation appears | Communication with the control element | Tooltip |
| Sequence View | Frame transition direction | Carousel |
If the result is already obvious, the additional effect may be unnecessary. Use loading state to wait for data, and Progress for known progress percentage.
Three principles
Ant Design offers natural, fast and discreet movement. A transition should link states, leave the interface responsive, and occupy only as much attention as the task requires.
Avoid the complex trajectory of the secondary indicator. The contents of the expanded menu are more important than the effect of rotating its arrow. Closing a panel usually requires less attention than introducing new content.
Check the transition with a series of actions: the user can change the selection again while the previous effect is still running. The current value and handlers must match the last action.
Duration and performance
The current topic has motionDurationFast, motionDurationMid, motionDurationSlow and motionEase* curves. Get them from theme.useToken() if the native element needs to match the app's theme.
Transform is suitable for simple movement: it preserves the element’s place in the layout. You can use opacity to appear. Changes to height or width are sometimes necessary, but require separate checking of the content and adjacent blocks. Don't add persistent animation to an element that is simply waiting for user action.
Do not wait to save the value or display the result until the end of the decorative transition. Even with motion disabled, the action should complete and remain accessible from the keyboard.
Motion reduction
In ConfigProvider.theme.token you can set motion:false. Native CSS effects must take this setting into account explicitly; Just having a design token is not enough for third party CSS. In the example, the duration of the own transition becomes zero when motion is turned off.
Additionally consider prefers-reduced-motion:reduce. In the example, the CSS disables movement on the system setting, preserving the final card position and result text. Disabling motion should not hide content or deprive the user of feedback.
Controlled transition
Click Move Card: It moves between the start and end of the track. Pressing again changes direction. The field below the track remains available and saves the entered text.
The “No animation in example” switch changes motion only in the ConfigProvider nested area. The child component reads the tokens of this scope. Both files are included in the card source code so that the entire example can be transferred.
Movement by action
The transition reads the nested topic tokens and takes into account the systemic reduction in movement.
MotionExample.svelte<script lang="ts"> import { Checkbox, ConfigProvider } from '@woodger/antd'; import MotionScene from './MotionScene.svelte'; let disabled = $state(false); </script> <style> .example { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; } </style> <div class="example"> <Checkbox bind:checked={disabled}>{("Without animation in the example")}</Checkbox> <ConfigProvider theme={{ token: { motion: !disabled } }}> <MotionScene /> </ConfigProvider> </div>MotionScene.svelte<script lang="ts"> import { Button, Input, theme } from '@woodger/antd'; let moved = $state(false); let draft = $state(''); const current = theme.useToken(); const duration = $derived( current.token.motion ? current.token.motionDurationMid : '0s' ); </script> <style> .scene { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; } .stage { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 12px; border: 1px solid var(--ant-color-border-secondary); border-radius: var(--ant-border-radius-lg); background: var(--ant-color-bg-layout); } .tile { display: grid; place-items: center; min-width: 0; height: 72px; border-radius: var(--ant-border-radius); background: var(--ant-color-primary-bg); color: var(--ant-color-primary-text); transition: transform var(--guide-motion-duration) var(--guide-motion-easing); } .tile.moved { transform: translateX(100%); } .scene:dir(rtl) .tile.moved { transform: translateX(-100%); } label { display: grid; gap: 8px; } output { overflow-wrap: anywhere; } @media (prefers-reduced-motion: reduce) { .tile { transition: none; } } </style> <div class="scene" style={` --guide-motion-duration: ${duration}; --guide-motion-easing: ${current.token.motionEaseInOut}; `}> <div class="stage" aria-hidden="true" ><div class="tile" class:moved >{("Card")}</div></div> <div> <Button aria-pressed={moved} onclick={() => { moved = !moved; }}> {("Move card")} </Button> </div> <output aria-label={("Card position")}>{(moved ? "End of track" : "Start of track")}</output> <label>{("Draft\n ")}<Input aria-label={("Draft movement")} bind:value={draft} style="width:100%" /> </label> <output aria-label={("Transition duration")} >{("Duration: ")}{duration}</output> </div>
Status and Focus
Moving an element does not require re-creating the form or losing focus. The decorative example card is excluded from the accessibility tree, and the position is reported as a separate text result.
For a truly hidden panel, transparency alone is not enough: invisible fields should not accidentally remain accessible via Tab. Hiding behavior, DOM destruction, and focus restoration are selected by the specific component's API. To open a self-contained task, use Modal rather than a self-made transparent layer.
Why motion matters
Motion connects a state change with an action, supports naturalness and makes results noticeable. Evaluate it by what a person understood: where a panel came from, which record changed or whether an operation finished. Repeating decorative motion should not compete with work.
Natural, performant and concise
Natural motion uses understandable direction and acceleration. Performant motion keeps content available without overloading the page. Concise motion shows only a meaningful change. Coordinate durations and curves across related components and check behaviour on an actual device.
When motion is disabled, preserve the action, final position, focus and clear feedback.
Adapted from the guide by Ant Design. MIT.