Skip to content
oxidaseSign in

Motion

Quiet feedback, a short rise for disclosure, one entrance per view, and nothing that loops.

Feedback

Motion answers the pointer and then stops. A button lifts 1px on hover over 150ms and settles on press over 90ms; a trailing arrow steps 3px forward; a linked card lifts 2px and its edge strengthens. Nothing loops for attention, and nothing moves while disabled.

Spatial hold

Lifts under a pointer

Code
<Button variant="primary" iconEnd={<Icon icon={ArrowRight} size="small" />}>
  Begin session
</Button>
<Button>View record</Button>
<SurfaceLink
  href="/design/foundations/motion#feedback"
  padding="compact"
  xstyle={{ k7Eaqz: "x12kinc7", $$css: true }}
>
  <Text variant="title">Spatial hold</Text>
  <Text variant="small" tone="secondary">Lifts under a pointer</Text>
</SurfaceLink>

Disclosure and entrance

Menus, popovers and dialogs rise 4px over 200ms as they open and fade out over motion.out as they close, letting clicks through while they go. A disclosure eases its height open and shut, and a list that filters eases to its new height with useEasedHeight instead of jumping. A view has one entrance when it first loads: its content fades in and rises 12px over 520ms on motion.easeEnter. Use motionStyles.enter, and enterDelay(i) to stagger a list; never fade sections in as the page scrolls.

hover, 150msFeedback: a lift, a press, a toggle

base, 200msDisclosure: a menu, popover or dialog rising

enter, 520msThe one entrance when a view loads

Code
"use client";

import * as stylex from "@stylexjs/stylex";
import { useState } from "react";
import { Button, textStyles } from "@oxidase/ui";
import { color, motion, radius, space } from "@oxidase/ui/tokens.stylex";

const ROWS = [
  { key: "hover", label: "hover, 150ms", use: "Feedback: a lift, a press, a toggle" },
  { key: "base", label: "base, 200ms", use: "Disclosure: a menu, popover or dialog rising" },
  { key: "enter", label: "enter, 520ms", use: "The one entrance when a view loads" },
] as const;

/** Plays each duration over the same distance. Under reduced motion the marks jump, because the reset removes transitions. */
export function DurationDemo() {
  const [moved, setMoved] = useState(false);
  return (
    <div {...stylex.props(styles.demo)}>
      {ROWS.map((row) => (
        <div key={row.key} {...stylex.props(styles.row)}>
          <p {...stylex.props(textStyles.small, textStyles.secondary, styles.label)}>
            <span {...stylex.props(textStyles.meta, textStyles.ink)}>{row.label}</span>
            {row.use}
          </p>
          <span {...stylex.props(styles.track)} aria-hidden="true">
            <span {...stylex.props(styles.mark, durations[row.key], moved && styles.moved)} />
          </span>
        </div>
      ))}
      <div>
        <Button onClick={() => setMoved((value) => !value)} pressed={moved}>
          {moved ? "Play back" : "Play"}
        </Button>
      </div>
    </div>
  );
}

const styles = stylex.create({
  demo: {
    display: "flex",
    flexDirection: "column",
    gap: space.s16,
    width: "100%",
  },
  row: {
    display: "grid",
    gap: space.s8,
  },
  label: {
    alignItems: "baseline",
    display: "flex",
    flexWrap: "wrap",
    gap: space.s8,
  },
  track: {
    backgroundColor: color.surfaceInset,
    borderRadius: radius.cell,
    display: "block",
    height: space.s12,
    position: "relative",
  },
  mark: {
    backgroundColor: color.ink,
    borderRadius: radius.mark,
    height: space.s12,
    insetInlineStart: 0,
    position: "absolute",
    top: 0,
    transform: "translateX(0)",
    transitionProperty: "inset-inline-start, transform",
    transitionTimingFunction: motion.emphasized,
    width: space.s24,
  },
  moved: {
    insetInlineStart: "100%",
    transform: "translateX(-100%)",
  },
});

const durations = stylex.create({
  hover: { transitionDuration: motion.hover },
  base: { transitionDuration: motion.base },
  enter: { transitionDuration: motion.enter, transitionTimingFunction: motion.easeEnter },
});

Data that moves

Numbers count between real values over motion.tick; rings and bars draw in when they first show and move when the value changes, over motion.fill. The done part is solid over the empty track, and an arc covers exactly its share: nothing still to come is drawn as filled. Figures keep their width while they count, and assistive technology reads only the final value.

6of 20 XP

61of 225 topics secured

Code
"use client";

import * as stylex from "@stylexjs/stylex";
import { useState } from "react";
import { Button, NumberTick, ProgressBar, ProgressRing, textStyles } from "@oxidase/ui";
import { layout, space } from "@oxidase/ui/tokens.stylex";
import { media } from "@oxidase/ui/media.stylex";

const GOAL = 20;
const TOPICS = 225;

/**
 * Earned XP toward a daily goal, and topics secured in a course. Invented
 * numbers: a lesson adds to both, and a new day empties the ring while the
 * course keeps its topics.
 */
export function DataMotionDemo() {
  const [xp, setXp] = useState(6);
  const [secured, setSecured] = useState(61);
  return (
    <div {...stylex.props(styles.demo)}>
      <div {...stylex.props(styles.figures)}>
        <ProgressRing value={xp} max={GOAL} size={128} thickness={12} tone="earned" label="XP today toward the daily goal">
          <span {...stylex.props(textStyles.figure)}>
            <NumberTick value={xp} />
          </span>
          <span {...stylex.props(textStyles.small, textStyles.tertiary)}>of {GOAL} XP</span>
        </ProgressRing>
        <div {...stylex.props(styles.course)}>
          <p {...stylex.props(styles.figureRow)}>
            <span {...stylex.props(textStyles.figure)}>
              <NumberTick value={secured} from={0} />
            </span>
            <span {...stylex.props(textStyles.small, textStyles.secondary)}>of {TOPICS} topics secured</span>
          </p>
          <ProgressBar value={secured} max={TOPICS} label="Topics secured in Algebra I" />
        </div>
      </div>
      <div {...stylex.props(styles.actions)}>
        <Button
          onClick={() => {
            setXp((value) => Math.min(GOAL, value + 5));
            setSecured((value) => Math.min(TOPICS, value + 12));
          }}
        >
          Add a lesson
        </Button>
        <Button onClick={() => setXp(0)}>Next day</Button>
      </div>
    </div>
  );
}

const styles = stylex.create({
  demo: {
    display: "flex",
    flexDirection: "column",
    gap: space.s24,
    width: "100%",
  },
  figures: {
    alignItems: "center",
    display: "grid",
    gap: layout.gap,
    gridTemplateColumns: { default: "minmax(0, 1fr)", [media.medium]: "auto minmax(0, 1fr)" },
  },
  course: {
    display: "flex",
    flexDirection: "column",
    gap: space.s12,
    minWidth: 0,
  },
  figureRow: {
    alignItems: "baseline",
    display: "flex",
    flexWrap: "wrap",
    gap: space.s8,
  },
  actions: {
    display: "flex",
    flexWrap: "wrap",
    gap: space.s12,
  },
});

Charts answer the pointer and the keyboard: bars grow from their baseline once (motionStyles.growY), and TrackingTooltip glides a small card to the mark being pointed at or focused while the other marks step back (trackingStyles.mark). The card never covers its mark and never takes a click; each mark names itself.

Code
"use client";

import * as stylex from "@stylexjs/stylex";
import { TrackingTooltip, enterDelay, motionStyles, textStyles, trackingStyles } from "@oxidase/ui";
import { color, data, radius, space } from "@oxidase/ui/tokens.stylex";

/* Invented XP for the example. */
const WEEK = [
  { day: "Mon", xp: 12 },
  { day: "Tue", xp: 20 },
  { day: "Wed", xp: 6 },
  { day: "Thu", xp: 24 },
  { day: "Fri", xp: 15 },
  { day: "Sat", xp: 0 },
  { day: "Sun", xp: 18 },
];
const MOST = 24;

/**
 * XP by day. The bars grow from the baseline once; pointing at a bar, or
 * moving through them with Tab, glides a small card to it while the others
 * step back. Each bar names itself for assistive technology.
 */
export function ChartDemo() {
  return (
    <TrackingTooltip>
      <div role="list" aria-label="XP earned each day this week" {...stylex.props(styles.chart)}>
        {WEEK.map((entry, index) => {
          const words = `${entry.day}: ${entry.xp} XP`;
          return (
            <div key={entry.day} role="listitem" {...stylex.props(styles.column)}>
              <span
                tabIndex={0}
                aria-label={words}
                data-tip={words}
                {...stylex.props(styles.slot, trackingStyles.mark)}
              >
                <span
                  {...stylex.props(
                    styles.bar,
                    entry.xp ? styles.observed : styles.none,
                    heights.of(`${Math.max(4, (entry.xp / MOST) * 100)}%`),
                    motionStyles.growY,
                    enterDelay(index),
                  )}
                />
              </span>
              <span aria-hidden="true" {...stylex.props(textStyles.small, textStyles.tertiary)}>
                {entry.day}
              </span>
            </div>
          );
        })}
      </div>
    </TrackingTooltip>
  );
}

const styles = stylex.create({
  chart: {
    alignItems: "end",
    borderBottomColor: color.hairlineStrong,
    borderBottomStyle: "solid",
    borderBottomWidth: 1,
    display: "grid",
    gap: space.s12,
    gridTemplateColumns: "repeat(7, minmax(0, 1fr))",
    paddingTop: space.s48,
  },
  column: {
    alignItems: "center",
    display: "flex",
    flexDirection: "column",
    gap: space.s8,
  },
  slot: {
    alignItems: "flex-end",
    borderRadius: radius.mark,
    display: "flex",
    height: "8rem",
    justifyContent: "center",
    outlineOffset: space.s4,
    width: "100%",
  },
  bar: {
    borderRadius: radius.mark,
    display: "block",
    width: "min(100%, 2rem)",
  },
  observed: {
    backgroundColor: data.observed,
  },
  none: {
    backgroundColor: data.empty,
  },
});

const heights = stylex.create({
  of: (height: string) => ({ height }),
});

Loading becomes loaded in one quick cross-fade in the same space: Reveal fades the content in where its skeleton was. Shape the skeleton like the content, so nothing below moves.

  • Machine3 of 4 right
  • Spatial holdHeld 6 of 8 cells
Code
"use client";

import { useEffect, useState } from "react";
import { Button, ListRow, Reveal, RowGroup, Skeleton, Stack } from "@oxidase/ui";

/* Invented sessions for the example. Loading takes a moment, as a real request does. */
const SESSIONS = [
  { id: "a", title: "Machine", detail: "3 of 4 right" },
  { id: "b", title: "Spatial hold", detail: "Held 6 of 8 cells" },
];

/** Loading to loaded as one quick cross-fade, in the same space. */
export function RevealDemo() {
  const [ready, setReady] = useState(true);
  useEffect(() => {
    if (ready) return;
    const timer = window.setTimeout(() => setReady(true), 1200);
    return () => window.clearTimeout(timer);
  }, [ready]);
  return (
    <Stack gap="s16">
      <div>
        <Button onClick={() => setReady(false)} disabled={!ready}>
          Load again
        </Button>
      </div>
      <Reveal
        ready={ready}
        fallback={<Skeleton height="9.5375rem" shape="block" />}
      >
        <RowGroup>
          {SESSIONS.map((session) => (
            <ListRow key={session.id} title={session.title} detail={session.detail} />
          ))}
        </RowGroup>
      </Reveal>
    </Stack>
  );
}

Steps, answers and earned moments

A runner shows one step at a time: StepTransition brings the next step in from ahead and the previous one from behind, while the step that left fades out quickly. Set initial={false} to skip its first entrance, and easeHeight in a dialog, so it eases from one step's height to the next. A right answer pops (motionStyles.correct); a wrong one shakes twice in under 320ms (motionStyles.wrong). What was earned celebrates once with Celebration, and flyTo carries the XP to where it counts. The words always say what happened too.

Question 1 of 3

What is 3 × 4?

6of 20
Code
"use client";

import * as stylex from "@stylexjs/stylex";
import { ArrowLeft, ArrowRight } from "lucide-react";
import { useRef, useState } from "react";
import {
  Button,
  Celebration,
  FormStatus,
  Icon,
  NumberTick,
  ProgressRing,
  StatusBadge,
  StepTransition,
  flyTo,
  motionStyles,
  textStyles,
} from "@oxidase/ui";
import { color, layout, radius, size, space } from "@oxidase/ui/tokens.stylex";
import { media } from "@oxidase/ui/media.stylex";

/* Invented questions for the example. */
const STEPS = [
  { prompt: "What is 3 × 4?", options: ["7", "12", "34"], answer: "12" },
  { prompt: "What is 5 + 8?", options: ["13", "15", "58"], answer: "13" },
  { prompt: "What is 9 − 6?", options: ["3", "4", "15"], answer: "3" },
] as const;

const GOAL = 20;
const AWARD = 5;

/**
 * Steps of a lesson, one at a time. A right answer pops and its XP flies to
 * the goal; a wrong one shakes once. Nothing is recorded here.
 */
export function MomentsDemo() {
  const [index, setIndex] = useState(0);
  const [direction, setDirection] = useState<"forward" | "back">("forward");
  const [picked, setPicked] = useState<Record<number, string>>({});
  const [xp, setXp] = useState(6);
  const [wrongs, setWrongs] = useState(0);
  const [status, setStatus] = useState("");
  const award = useRef<HTMLSpanElement>(null);
  const ring = useRef<HTMLDivElement>(null);
  const step = STEPS[index];
  const choice = picked[index];
  const right = choice === step.answer;

  const go = (next: number) => {
    setDirection(next > index ? "forward" : "back");
    setIndex(next);
  };

  const check = async (option: string) => {
    if (choice === step.answer) return;
    setPicked((current) => ({ ...current, [index]: option }));
    if (option !== step.answer) {
      setWrongs((count) => count + 1);
      setStatus(`${option} is not right. Try again.`);
      return;
    }
    setStatus(`Right. ${AWARD} XP earned.`);
    await new Promise((resolve) => requestAnimationFrame(resolve));
    if (award.current && ring.current) await flyTo({ from: award.current, to: ring.current, label: `+${AWARD} XP` });
    setXp((value) => Math.min(GOAL, value + AWARD));
  };

  return (
    <div {...stylex.props(styles.demo)}>
      <div {...stylex.props(styles.lesson)}>
        <StepTransition stepKey={String(index)} direction={direction}>
          <p {...stylex.props(textStyles.small, textStyles.tertiary)}>
            Question {index + 1} of {STEPS.length}
          </p>
          <p data-step-focus tabIndex={-1} {...stylex.props(textStyles.prompt, styles.prompt)}>
            {step.prompt}
          </p>
          <div role="group" aria-label="Answers" {...stylex.props(styles.options)}>
            {step.options.map((option) => {
              const chosen = choice === option;
              return (
                <button
                  key={chosen && !right ? `${option}-${wrongs}` : option}
                  type="button"
                  aria-pressed={chosen}
                  onClick={() => check(option)}
                  {...stylex.props(
                    styles.option,
                    motionStyles.press,
                    chosen && (right ? styles.optionRight : styles.optionWrong),
                    chosen && (right ? motionStyles.correct : motionStyles.wrong),
                  )}
                >
                  {option}
                </button>
              );
            })}
          </div>
          <div {...stylex.props(styles.result)}>
            {right ? (
              <Celebration trigger={right}>
                <span ref={award}>
                  <StatusBadge tone="earned">+{AWARD} XP</StatusBadge>
                </span>
              </Celebration>
            ) : null}
          </div>
        </StepTransition>
        <div {...stylex.props(styles.nav)}>
          <Button icon={<Icon icon={ArrowLeft} size="small" />} disabled={index === 0} onClick={() => go(index - 1)}>
            Back
          </Button>
          <Button variant="primary" iconEnd={<Icon icon={ArrowRight} size="small" />} disabled={index === STEPS.length - 1} onClick={() => go(index + 1)}>
            Next
          </Button>
        </div>
        <FormStatus>{status}</FormStatus>
      </div>
      <div ref={ring} {...stylex.props(styles.goal)}>
        <ProgressRing value={xp} max={GOAL} size={112} thickness={10} tone="earned" label="XP today toward the daily goal">
          <span {...stylex.props(textStyles.figure)}>
            <NumberTick value={xp} />
          </span>
          <span {...stylex.props(textStyles.small, textStyles.tertiary)}>of {GOAL}</span>
        </ProgressRing>
      </div>
    </div>
  );
}

const styles = stylex.create({
  demo: {
    alignItems: "start",
    display: "grid",
    gap: layout.gap,
    gridTemplateColumns: { default: "minmax(0, 1fr)", [media.medium]: "minmax(0, 1fr) auto" },
    width: "100%",
  },
  lesson: {
    display: "flex",
    flexDirection: "column",
    gap: space.s16,
    minWidth: 0,
  },
  prompt: {
    marginBlock: space.s8,
    outline: "none",
  },
  options: {
    display: "flex",
    flexWrap: "wrap",
    gap: space.s8,
  },
  option: {
    backgroundColor: { default: color.surface, ":hover": color.tonal },
    borderRadius: radius.md,
    boxShadow: `inset 0 0 0 1px ${color.controlBorder}`,
    color: color.ink,
    cursor: "pointer",
    fontSize: "1.125rem",
    minHeight: size.controlLarge,
    minWidth: "4.5rem",
    paddingInline: space.s16,
  },
  optionRight: {
    boxShadow: `inset 0 0 0 2px ${color.indicator}`,
  },
  optionWrong: {
    boxShadow: `inset 0 0 0 2px ${color.danger}`,
  },
  result: {
    alignItems: "center",
    display: "flex",
    minHeight: "1.75rem",
  },
  nav: {
    display: "flex",
    flexWrap: "wrap",
    gap: space.s12,
  },
  goal: {
    justifySelf: { default: "start", [media.medium]: "end" },
  },
});

Changing what a place shows

When one place swaps what it shows, such as a week for a month, startViewTransition lets the browser cross-fade the old view into the new. Under reduced motion, or where the browser has none, the swap is immediate. Never use it on an exercise screen.

This week

95 XP

5 of 7 days practised

Code
"use client";

import * as stylex from "@stylexjs/stylex";
import { useState } from "react";
import { flushSync } from "react-dom";
import { Button, Cluster, Stack, Text, startViewTransition } from "@oxidase/ui";
import { color, radius, space } from "@oxidase/ui/tokens.stylex";

/* Invented totals for the example. */
const VIEWS = {
  week: { title: "This week", figure: "95 XP", detail: "5 of 7 days practised" },
  month: { title: "This month", figure: "412 XP", detail: "19 of 30 days practised" },
} as const;

/** One place showing different content: the browser cross-fades the swap. */
export function ViewSwapDemo() {
  const [view, setView] = useState<keyof typeof VIEWS>("week");
  const show = (next: keyof typeof VIEWS) => {
    if (next === view) return;
    void startViewTransition(() => flushSync(() => setView(next)));
  };
  const current = VIEWS[view];
  return (
    <Stack gap="s16">
      <Cluster gap="s8">
        <Button pressed={view === "week"} onClick={() => show("week")}>
          Week
        </Button>
        <Button pressed={view === "month"} onClick={() => show("month")}>
          Month
        </Button>
      </Cluster>
      <div {...stylex.props(styles.panel)}>
        <Text variant="title">{current.title}</Text>
        <Text variant="figure">{current.figure}</Text>
        <Text variant="small" tone="secondary">
          {current.detail}
        </Text>
      </div>
    </Stack>
  );
}

const styles = stylex.create({
  panel: {
    backgroundColor: color.surface,
    borderColor: color.hairline,
    borderRadius: radius.lg,
    borderStyle: "solid",
    borderWidth: 1,
    display: "flex",
    flexDirection: "column",
    gap: space.s8,
    padding: space.s24,
  },
});

Durations and easing

Feedback uses motion.press and motion.hover, disclosure motion.base, and the entrance motion.enter. The curves below are drawn from the tokens' own control points.

motion.emphasizedFeedback and disclosure: quick to respond, soft to settle.
motion.easeEnterThe one entrance: a long, gentle arrival.
motion.exitLeaving: accelerates away and is gone.

Reduced motion

Members choose reduced motion in Appearance, or leave it on Automatic to follow the device. The resolved setting is written to the page before it paints, and one rule in the reset removes every transition and settles every animation on its final frame. Lifts, presses and entrances are gone; a spinner becomes three still dots.

TurningReduced

Components refine the reset when an offset would otherwise still jump, reading the same attribute through the page marker. Script that animates reads it with useReducedMotion(), and celebrations fall back to a brief fade.

const styles = stylex.create({
  panel: {
    transitionDuration: motion.base,
    transitionProperty: "opacity, transform",
    transform: {
      default: "translateY(0)",
      // The reset already zeroes durations; this removes the offset too.
      [stylex.when.ancestor('[data-motion="reduce"]', pageMarker)]: "none",
    },
  },
});

Reduced means no movement, not slower movement

Opacity may still change instantly so state stays visible. Position, scale and scrolling do not animate.

Still in a task area

  • Nothing moves inside a task area unless its protocol defines it: cells appear and disappear in one frame, owned by the protocol.
  • The Spatial hold route is excluded from page transitions, so its stimulus never appears under a fade.
  • A change of theme, motion setting or grid size during a Spatial hold trial is recorded with that trial, and the trial is not used in estimates.
  • Design system durations never time a trial. Timing lives in the measurement code.