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

TokenValueGroup
--ws-motion-duration-stagger40msduration
--ws-motion-duration-micro80msduration
--ws-motion-duration-quick150msduration
--ws-motion-duration-fast250msduration
--ws-motion-duration-medium350msduration
--ws-motion-duration-slow400msduration
--ws-motion-duration-very-slow500msduration
--ws-motion-ease-smooth-outcubic-bezier(0.22, 1, 0.36, 1)ease
--ws-motion-ease-in-outease-in-outease
--ws-motion-ease-outease-outease
--ws-motion-ease-linearlinearease
--ws-motion-ease-bouncecubic-bezier(0.34, 1.36, 0.64, 1)ease
--ws-motion-ease-bounce-strongcubic-bezier(0.34, 1.85, 0.64, 1)ease
--ws-motion-distance-micro4pxdistance
--ws-motion-distance-small6pxdistance
--ws-motion-distance-base8pxdistance
--ws-motion-distance-medium12pxdistance
--ws-motion-distance-large30pxdistance
--ws-motion-scale-large0.96scale
--ws-motion-scale-medium0.97scale
--ws-motion-scale-small0.98scale
--ws-motion-scale-tiny0.99scale
--ws-motion-blur-small2pxblur
--ws-motion-blur-medium3pxblur
--ws-motion-blur-large8pxblur