Motion
How components animate, how to turn it off, and the tokens behind it.
Components animate out of the box: press feedback, hover tints, menus, toasts, field errors.
Every transition reads its duration, easing, distance and scale from --ws-motion-* tokens,
and all of it respects prefers-reduced-motion. There is nothing to set up.
Only free-standing buttons shrink when pressed. Split buttons, fields, selects, tabs, chips and list rows change colour on press, never size.
Turn it off
MotionProvider for the whole app or a subtree, defaultMotion for one component. The prop
wins over the provider, so it can also switch motion back on inside a disabled subtree.
import { Button, MotionProvider } from '@wideset/react';
<MotionProvider enabled={false}>
<App />
</MotionProvider>
<Button defaultMotion={false}>Save</Button>
Change it
Redefine a token in your stylesheet, loaded after Wideset’s, and every component that reads it follows:
@media (prefers-reduced-motion: no-preference) {
:root {
--ws-motion-duration-quick: 100ms; /* snappier hovers and closes */
--ws-motion-scale-small: 1; /* buttons do not shrink on press */
}
}
For one component, switch its motion off and add your own classes:
<Button
defaultMotion={false}
className="hover:opacity-80 motion-safe:transition-opacity motion-safe:duration-300"
>
Save
</Button>
Shake on validation
useShake plays a short horizontal shake on a field to flag a rejected value. It returns a
ref for TextInput or Textarea and a shake() to call when validation fails; calling it
again restarts the animation.
Shake
Submit without an @ to see the field shake.
Tokens
| Token | Value | Group |
|---|---|---|
--ws-motion-duration-stagger | 40ms | duration |
--ws-motion-duration-micro | 80ms | duration |
--ws-motion-duration-quick | 150ms | duration |
--ws-motion-duration-fast | 250ms | duration |
--ws-motion-duration-medium | 350ms | duration |
--ws-motion-duration-slow | 400ms | duration |
--ws-motion-duration-very-slow | 500ms | duration |
--ws-motion-ease-smooth-out | cubic-bezier(0.22, 1, 0.36, 1) | ease |
--ws-motion-ease-in-out | ease-in-out | ease |
--ws-motion-ease-out | ease-out | ease |
--ws-motion-ease-linear | linear | ease |
--ws-motion-ease-bounce | cubic-bezier(0.34, 1.36, 0.64, 1) | ease |
--ws-motion-ease-bounce-strong | cubic-bezier(0.34, 1.85, 0.64, 1) | ease |
--ws-motion-distance-micro | 4px | distance |
--ws-motion-distance-small | 6px | distance |
--ws-motion-distance-base | 8px | distance |
--ws-motion-distance-medium | 12px | distance |
--ws-motion-distance-large | 30px | distance |
--ws-motion-scale-large | 0.96 | scale |
--ws-motion-scale-medium | 0.97 | scale |
--ws-motion-scale-small | 0.98 | scale |
--ws-motion-scale-tiny | 0.99 | scale |
--ws-motion-blur-small | 2px | blur |
--ws-motion-blur-medium | 3px | blur |
--ws-motion-blur-large | 8px | blur |