Motion

Two switches and a duration scale a page sets in CSS — transitions and animations, controlled separately, cheap by rule, and the same for every component.

Motion in FlexPixels is controlled by three CSS custom properties and nothing else — no attribute, no JavaScript flag, no class. Set them on :root for the page, on any element for the region inside it, or on one component. They inherit. In your own CSS an element reads the switches from its parent, so a switch set on an element reaches its descendants and not the element itself: to stop an element’s own motion, set the switch on its parent.

SwitchValuesGoverns
--fp-transitionsnormal · reduced · noneTransitions — a component moving between states because someone or the app changed it
--fp-animationsnormal · reduced · noneAnimations — motion that appears, loops, or follows data or time (spinners, shimmers, a countdown)
--fp-motion-scalea number above 0 (default 1)Multiplies every duration and delay: 2 is twice as slow, 0.5 twice as fast
css
:root {
  --fp-transitions: none;
  --fp-animations: none;
} /* the whole page, still */
:root {
  --fp-animations: none;
} /* state changes stay, ambient motion stops */
.kiosk {
  --fp-transitions: reduced;
  --fp-animations: reduced;
}
:root {
  --fp-motion-scale: 0.8;
} /* everything 20% faster */
html
<fp-drawer style="--fp-transitions: none"></fp-drawer>

From a user setting, set the property and tell components that run JavaScript motion:

js
document.documentElement.style.setProperty("--fp-animations", "none");
document.dispatchEvent(new Event("fp-motion-change"));

Transition or animation — the trigger decides

A transition answers something that happened: hover, focus, press, drag, scroll, open, select, toggle, or a state the app set. An animation appears, loops, or follows data or time: load, loop, data, time. The two are switched separately because they are different things to a person — someone who wants a calm page usually still wants a menu to open.

The levels

LevelTransitionsAnimations
normalThe designed transitionThe designed animation
reducedNo travel (no translate, scale or rotate); colour and opacity over half the timeNo loop of travel; an animation that carries meaning (a loading indicator) shows its calm form
noneInstant: the end state appears at onceNothing runs; the component shows its still state and still says what it means

A value that is not a level — off, false, a typo — is invalid and ignored: the element keeps the level it inherits (normal if no ancestor sets one). The switches are registered with @property, so this is exact, not a best guess. There is no off; use none.

The operating system preference

prefers-reduced-motion: reduce turns normal into reduced. none stays none. A page can take motion away; it can never give back what the person asked the system to remove.

How it works

The switches are the only public surface. Each component that moves adopts one shared sheet, generated from the theme, that turns the levels into the numbers every duration is multiplied by. It is computed per element, so a switch set on a component reaches every part inside it:

:host, * {
  --_motion-time: max(var(--fp-motion-scale, 1), 0.01);
  --_motion-travel: 1;
  --_motion-anim-time: max(var(--fp-motion-scale, 1), 0.01);
  --_motion-calm-time: 0;
}

/* The OS preference, on its own: where style queries are not supported, or the scope
   has no container to query (:root), nothing below would apply it. Later rules refine. */
@media (prefers-reduced-motion: reduce) {
  :host, * {
    --_motion-time: calc(0.5 * max(var(--fp-motion-scale, 1), 0.01));
    --_motion-travel: 0;
    --_motion-anim-time: 0;
    --_motion-calm-time: max(var(--fp-motion-scale, 1), 0.01);
  }
}

@container style(--fp-transitions: reduced) {
  :host, * {
    --_motion-time: calc(0.5 * max(var(--fp-motion-scale, 1), 0.01));
    --_motion-travel: 0;
  }
}

@container style(--fp-transitions: none) {
  :host, * {
    --_motion-time: 0;
    --_motion-travel: 0;
  }
}

@container style(--fp-animations: reduced) {
  :host, * {
    --_motion-anim-time: 0;
    --_motion-calm-time: max(var(--fp-motion-scale, 1), 0.01);
  }
}

@container style(--fp-animations: none) {
  :host, * {
    --_motion-anim-time: 0;
    --_motion-calm-time: 0;
  }
}

/* The OS preference can only take motion away: normal becomes reduced, none stays none. */
@media (prefers-reduced-motion: reduce) {
  @container style(--fp-transitions: normal) {
    :host, * {
      --_motion-time: calc(0.5 * max(var(--fp-motion-scale, 1), 0.01));
      --_motion-travel: 0;
    }
  }

  @container style(--fp-animations: normal) {
    :host, * {
      --_motion-anim-time: 0;
      --_motion-calm-time: max(var(--fp-motion-scale, 1), 0.01);
    }
  }
}
  • --_motion-time multiplies a transition’s duration; --_motion-travel its distance.
  • --_motion-anim-time multiplies the designed animation; --_motion-calm-time its calm form.

A zero-duration animation finishes at once and never ticks, so a component lists its designed animation and its calm one together and the numbers choose — no second rule, no JavaScript.

Your own CSS

The numbers are private to components, so your own stylesheet does not see them by default. Generate the same mapping for your own scope and multiply your durations by it; your motion then follows the switches and the OS preference exactly as the components do.

ts
import { generateMotionCSS } from "@flexpixels/cortex";
const css = generateMotionCSS("fp", ".app, .app *"); // write it into your stylesheet

The scope is elements that have a parent: each one reads the switches from the element above it. The root element has none, so a level set there would be ignored: the function throws for any scope whose selector can match the root (:root or html in any letter case, with a class such as html.dark, or inside :where() / :is()), and for a prefix or scope that is not safe to write into CSS. Use ":root *" to cover the whole page.

css
.app .panel {
  transition: translate calc(var(--fp-transition-duration-slow) * var(--_motion-time))
    var(--fp-transition-easing);
}
.app .panel:not(.open) {
  translate: 0 calc(100% * var(--_motion-travel));
}

What may move

Motion must not cost more than it gives. In a component’s stylesheet:

  • Compositor-only properties move: transform, translate, scale, rotate, opacity.
  • Discrete properties may change too: display, overlay, visibility, content-visibility.
  • A transition may also change paint-only properties (colours, stroke dashes).
  • Anything else — a size, grid-template-rows, box-shadow — runs only under a named, measured exception.

Three stylelint rules hold this (fp/motion-properties, fp/motion-duration, fp/motion-host), and a browser audit drives every component, lists what actually moved, and fails anything outside the rules or anything still moving at none.

Duration tokens

Durations come from the theme, and a component’s own hooks (--fp-{component}-*-duration) set its designed value. The switches and --fp-motion-scale apply on top of both.

TransitionsAnimations
--fp-transition-duration-xfast (full stylesheet only)--fp-animation-duration-enter
--fp-transition-duration-fast--fp-animation-duration-loop-fast
--fp-transition-duration-normal--fp-animation-duration-loop
--fp-transition-duration-slow--fp-animation-duration-loop-slow
--fp-transition-duration-xslow (full stylesheet only)

The default theme.css leaves out xfast and xslow; theme-full.css (or output.tokens: "full") has them. Easings are on the Interaction page.

What moves in each component

Generated from the stylesheets — the same data an agent reads from the full FlexPixels MCP server, @flexpixels/mcp (not yet published): its flexpixels://motion resource and the motion field of its components_get_css_hooks tool. The Cortex server, @flexpixels/cortex-mcp, does not serve them.

Component Part Kind Started by Moves
fp-accordion ::slotted transition scroll opacity, translate
fp-accordion-item item transition hover, toggle background, border-color, content-visibility, opacity
fp-accordion-item trigger transition focus, hover color
fp-accordion-item indicator transition hover, toggle background, border-color, color
fp-avatar surface transition state background, color
fp-avatar image animation load opacity
fp-avatar fallback animation load opacity
fp-badge surface transition state background, border-color, color
fp-bottom-nav-item base transition hover, select background, color
fp-bottom-nav-item label transition select opacity, scale
fp-breadcrumb-item link transition hover color
fp-button surface transition focus, hover, press, state background, border-color, color, opacity, transform
fp-button loading-icon animation loop opacity, transform
fp-button-group indicator transition select scale, translate
fp-calendar day-face transition hover, select background, color
fp-calendar cell-face transition hover, select background, color
fp-card surface transition hover background, border-color, opacity, transform
fp-carousel indicator transition select background
fp-chat-composer surface transition focus, hover background, border-color
fp-chat-composer send transition hover background-color, color, opacity
fp-chat-typing dot animation loop opacity, translate
fp-checkbox surface transition focus, hover, toggle background
fp-checkbox icon-wrapper transition toggle opacity, transform
fp-checkbox check-path transition toggle stroke-dashoffset
fp-checkbox indet-path transition toggle stroke-dashoffset
fp-chip surface transition hover, press, select background, border-color, color, transform
fp-chip remove-button transition hover background, color
fp-chooser-option surface transition hover, select background-color, border-color
fp-chooser-option control transition select background-color, border-color
fp-chooser-option control-mark transition select opacity
fp-chooser-option indicator transition select opacity, transform
fp-content-navigator item transition hover, select background-color, border-color, color
fp-context-menu surface transition open display, opacity, overlay, transform
fp-copy-button surface transition focus, hover, press, state background, border-color, color, opacity, transform
fp-copy-button icon animation loop opacity, transform
fp-data-grid header-cell-menu-trigger transition hover background, opacity
fp-data-grid header-cell-resize-handle transition hover background
fp-data-grid row transition hover, select background, opacity
fp-data-grid pin-shadow transition scroll opacity
fp-data-grid cell-skeleton animation loop translate
fp-drawer host transition open opacity
fp-drawer surface transition drag, open display, opacity, overlay, translate
fp-drop-down surface transition focus, hover background, border-color
fp-drop-down chevron transition open transform
fp-dropdown surface transition open opacity, transform
fp-field outline-start transition focus, hover, state border-color, color
fp-field outline-end transition focus, hover, state border-color, color
fp-field label transition focus, hover, state border-color, color
fp-field label-rule transition focus, hover, state border-color, color
fp-file-dropper drop-zone transition drag, hover background-color, border-color, transform
fp-flip-card faces transition toggle transform
fp-grid * transition scroll opacity, translate
fp-icon-button surface transition focus, hover, press, state background-color, border-color, color, opacity, transform
fp-icon-button content transition state opacity
fp-icon-button loading-icon animation loop opacity, transform
fp-input surface transition focus, hover background, border-color
fp-input clear transition hover color
fp-input password-toggle transition hover color
fp-list ::slotted transition scroll opacity, translate
fp-list-item item transition drag, hover, press background, color, transform
fp-logo-cloud ::slotted transition focus, hover, scroll opacity, translate
fp-marquee run animation loop transform
fp-menu-item item transition focus, hover background, color
fp-modal host transition open opacity
fp-modal dialog transition open display, opacity, overlay, transform
fp-modal dialog::backdrop transition open background-color, display, overlay
fp-navbar base transition scroll transform
fp-navbar-link link transition hover background, color
fp-navbar-trigger trigger transition hover background, color
fp-navbar-trigger caret transition open transform
fp-popover surface transition open opacity, transform
fp-progress fill animation data, loop opacity, scale, stroke-dasharray, stroke-dashoffset, transform, translate
fp-progress svg animation loop transform
fp-radio surface transition hover, toggle background
fp-radio indicator transition toggle opacity, transform
fp-radio-group ::slotted transition state opacity, translate
fp-select surface transition focus, hover background, border-color
fp-skeleton base animation loop opacity, transform
fp-slider thumb transition hover, press scale
fp-spinner visual animation loop opacity, transform
fp-spinner indicator animation loop stroke-dasharray, stroke-dashoffset
fp-spinner dot animation loop opacity, transform
fp-spinner bar animation loop opacity
fp-spinner ripple animation loop opacity, transform
fp-stack * transition scroll opacity, translate
fp-step connector transition state background
fp-step indicator transition state background, border-color
fp-switch surface transition hover, toggle background
fp-switch thumb transition toggle background, translate
fp-tab host transition hover, select background, color
fp-tabs indicator transition select opacity, scale, translate
fp-tag surface transition hover, state background-color, border-color, color
fp-tag-input surface transition focus, hover background, border-color
fp-textarea surface transition focus, hover background, border-color
fp-theme-switch button transition hover background
fp-theme-switch icon transition toggle opacity, transform
fp-theme-switch segment transition hover, select background, color
fp-toast surface transition open opacity, transform
fp-toast progress-ring animation time stroke-dashoffset
fp-toast-region ::slotted transition open, state opacity, transform
fp-toc mobile-chevron transition open transform
fp-toggle-button surface transition hover, press, toggle background, border-color, color, opacity, transform
fp-tree-item item transition hover, toggle background
fp-tree-item expand-toggle transition toggle rotate
fp-tree-item loading-indicator animation loop opacity, transform
fp-vision-switch select transition hover background-color
fp-vision-switch segment transition hover, select background-color, color