Interaction

Transition durations, easing curves, focus ring tokens and opacity — for consistent interaction design.

The Interaction System provides tokens for motion, focus indicators and opacity states. How motion is switched and reduced is on the Motion page.

Token Reference

Tokens

Durations

Key ms CSS variable Use
xfast 75 --fp-transition-duration-xfast Press feedback, tiny toggles. Full stylesheet only.
fast 100 --fp-transition-duration-fast Hover, focus micro-interactions
normal 150 --fp-transition-duration-normal Default state changes
slow 250 --fp-transition-duration-slow Enter/exit animations
xslow 400 --fp-transition-duration-xslow Large enter/exit (drawer, modal). Full stylesheet only.

Other

Token Value
--fp-opacity-disabled 0.5
--fp-scale-active 0.98
--fp-focus-ring-width 2px
--fp-focus-ring-offset 2px
--fp-focus-ring-color var(--fp-primary-text)

Shorthand aliases (point to the most common values):

AliasResolves toUse
--fp-transition-duration--fp-transition-duration-normalDefault duration for most transitions
--fp-transition-easing--fp-transition-easing-ease-outDefault easing for most transitions

Duration Ramp

Five duration steps span micro-feedback through large enter/exit motion. The default theme.css ships fast, normal and slow; xfast and xslow are in the full stylesheet only (theme-full.css, or output.tokens: "full").

TokenDefaultUse
--fp-transition-duration-xfast75msMicro-feedback (press, ripple, tiny toggles)
--fp-transition-duration-fast100msHover, focus, small toggles
--fp-transition-duration-normal150msDefault for most state changes
--fp-transition-duration-slow250msEnter/exit animations
--fp-transition-duration-xslow400msLarge enter/exit (drawer, modal, page)

Easing Curves

The base curves plus a Material-3-inspired semantic set — standard for most UI motion, emphasized for large/expressive motion, each with -decelerate (enter) and -accelerate (exit) partners. Override any curve via interaction.easings. standard-decelerate, standard-accelerate and emphasized-accelerate are in the full stylesheet only; the default theme.css has the rest.

TokenValueUse
--fp-transition-easing-ease-outcubic-bezier(0, 0, 0.2, 1)Exit/appear transitions
--fp-transition-easing-ease-in-outcubic-bezier(0.4, 0, 0.2, 1)State changes
--fp-transition-easing-linearcubic-bezier(0, 0, 1, 1)Progress, loading bars
--fp-transition-easing-standardcubic-bezier(0.2, 0, 0, 1)Most UI motion
--fp-transition-easing-standard-deceleratecubic-bezier(0, 0, 0, 1)Elements entering
--fp-transition-easing-standard-acceleratecubic-bezier(0.3, 0, 1, 1)Elements exiting
--fp-transition-easing-emphasizedcubic-bezier(0.2, 0, 0, 1)Large/expressive motion
--fp-transition-easing-emphasized-deceleratecubic-bezier(0.05, 0.7, 0.1, 1)Emphasized enter
--fp-transition-easing-emphasized-acceleratecubic-bezier(0.3, 0, 0.8, 0.15)Emphasized exit
--fp-transition-easing-springlinear(…)Sampled spring curve

--fp-transition-easing-spring is the spring below sampled into a CSS linear() easing; --fp-spring-duration is how long it takes to settle (498ms with the default spring).

Focus Ring

TokenDefaultUse
--fp-focus-ring-width2pxOutline width for focus indicators
--fp-focus-ring-offset2pxGap between element and focus ring
--fp-focus-ring-colorvar(--fp-primary-text)Focus ring color — the -text colour of the configured focusRing.color role

The focus ring color is configurable via interaction.focusRing.color in theme-config.json. It accepts any color role — "primary", "secondary", "neutral", "success", "danger", "warning" or "info". Default: "primary". It uses the role’s -text token rather than step 9 because that colour is measured against the page, so the ring stays visible even when the brand colour is pale.

State Tokens

TokenDefaultUse
--fp-opacity-disabled0.5Disabled-state opacity for any element
--fp-scale-active0.98Active-press scale effect
--fp-touch-target-min44pxMinimum hit area on coarse pointers
--fp-touch-target-comfortable48pxA roomier hit area

State-Layer Opacities

Material-3-style overlay opacities. Composite them as currentColor over any surface (via a pseudo-element or layered background) — because they use the text color, they flip with the color scheme automatically instead of needing separate light/dark values. The default theme.css ships hover and press; drag and selected are in the full stylesheet only, so the sample gives selected a fallback.

TokenDefaultUse
--fp-state-hover0.05Hover overlay opacity
--fp-state-press0.1Pressed/active overlay
--fp-state-drag0.14Dragged overlay
--fp-state-selected0.08Selected overlay
css
.item::after {
  content: "";
  position: absolute;
  inset: 0;
  background: currentColor;
  opacity: 0;
  transition: opacity var(--fp-transition-duration-fast) var(--fp-transition-easing-standard);
}
.item:hover::after {
  opacity: var(--fp-state-hover);
}
.item:active::after {
  opacity: var(--fp-state-press);
}
.item[aria-selected="true"]::after {
  opacity: var(--fp-state-selected, 0.08);
}

Spring Physics

The engine samples this spring into --fp-transition-easing-spring and --fp-spring-duration, which fp-drawer uses when it settles. Nothing reads stiffness, damping and mass at runtime: they record the spring the curve came from, and only the full stylesheet carries them. Change the spring in interaction.spring, not with these tokens.

TokenDefaultUse
--fp-spring-stiffness220Higher = snappier
--fp-spring-damping28Higher = less overshoot
--fp-spring-mass1Higher = more inertia
--fp-spring-duration498msSettle time (computed)

Stagger Delays

Per-item entrance delays for cascade animations. Multiply by the item’s index to offset each item; the FlexPixels list, grid and stack components read the index from --fp-index.

TokenDefaultUse
--fp-stagger-delay50msDefault per-item cascade
--fp-stagger-delay-fast40msTight cascade
--fp-stagger-delay-slow60msLoose cascade

How to Use

Button with transition

css
.button {
  transition:
    background var(--fp-transition-duration) var(--fp-transition-easing),
    box-shadow var(--fp-transition-duration) var(--fp-transition-easing),
    transform var(--fp-transition-duration-fast) var(--fp-transition-easing);
}
.button:hover {
  background: var(--fp-primary-10);
}
.button:active {
  transform: scale(var(--fp-scale-active));
}

Focus indicator

css
.button:focus-visible {
  outline: var(--fp-focus-ring-width) solid var(--fp-focus-ring-color);
  outline-offset: var(--fp-focus-ring-offset);
}

Disabled state

css
.button:disabled,
.button[aria-disabled="true"] {
  opacity: var(--fp-opacity-disabled);
  pointer-events: none;
}

Card hover with elevation transition

css
.card {
  box-shadow: var(--fp-elevation-1);
  transition: box-shadow var(--fp-transition-duration) var(--fp-transition-easing);
}
.card:hover {
  box-shadow: var(--fp-elevation-2);
}

Reduced Motion

There is no reduced-duration token. Motion is controlled by the switches — --fp-transitions, --fp-animations and --fp-motion-scale — and every component folds the OS preference (prefers-reduced-motion: reduce) into them for you: see Motion. The animation durations (--fp-animation-duration-*) are listed there too.

Your own CSS can follow the same switches: generate the mapping for your own scope and multiply your durations by its numbers.

ts
import { generateMotionCSS } from "@flexpixels/cortex";
const css = generateMotionCSS("fp", ".app, .app *");
css
.app .panel {
  transition: translate calc(var(--fp-transition-duration-slow) * var(--_motion-time))
    var(--fp-transition-easing);
}

Common Examples

Smooth dropdown open/close

css
.dropdown {
  opacity: 0;
  transform: translateY(-4px);
  transition:
    opacity var(--fp-transition-duration) var(--fp-transition-easing),
    transform var(--fp-transition-duration) var(--fp-transition-easing);
}
.dropdown[aria-expanded="true"] {
  opacity: 1;
  transform: translateY(0);
}

Loading spinner with linear easing

css
.spinner {
  animation: spin 1s var(--fp-transition-easing-linear) infinite;
}

Configuration

json
{
  "interaction": {
    "opacityDisabled": 0.5,
    "durations": {
      "xfast": 75,
      "fast": 100,
      "normal": 150,
      "slow": 250,
      "xslow": 400
    },
    "easings": { "standard": [0.2, 0, 0, 1] },
    "states": { "hover": 0.05, "press": 0.1, "drag": 0.14, "selected": 0.08 },
    "spring": { "stiffness": 220, "damping": 28, "mass": 1 },
    "stagger": { "delay": 50, "delayFast": 40, "delaySlow": 60 },
    "focusRing": {
      "width": 2,
      "offset": 2,
      "color": "primary"
    },
    "scaleActive": 0.98
  }
}

Every field is optional; a block you leave out, or leave partly empty, gets its defaults. animationDurations is covered on the Motion page.

PropertyDefaultDescription
opacityDisabled0.5Opacity multiplier for disabled elements (0–1)
durations.xfast75Extra-fast in ms. Micro-feedback (press, ripple).
durations.fast100Fast transition in ms. Hover states, small toggles.
durations.normal150Normal transition in ms. Standard state changes.
durations.slow250Slow transition in ms. Complex enter/exit animations.
durations.xslow400Extra-slow in ms. Large enter/exit (drawer, modal, page).
easings—Cubic-bezier override map ([x1,y1,x2,y2]) merged over the semantic set.
states.hover0.05Hover state-layer overlay opacity → --fp-state-hover.
states.press0.1Pressed state-layer opacity → --fp-state-press.
states.drag0.14Dragged state-layer opacity → --fp-state-drag.
states.selected0.08Selected state-layer opacity → --fp-state-selected.
spring.stiffness220Spring stiffness → --fp-spring-stiffness. Higher = snappier.
spring.damping28Spring damping → --fp-spring-damping. Higher = less overshoot.
spring.mass1Spring mass → --fp-spring-mass. Higher = more inertia.
stagger.delay50Per-item cascade delay in ms → --fp-stagger-delay.
stagger.delayFast40Tight cascade delay → --fp-stagger-delay-fast.
stagger.delaySlow60Loose cascade delay → --fp-stagger-delay-slow.
focusRing.width2Focus ring outline width in px.
focusRing.offset2Focus ring outline offset in px.
focusRing.color"primary"Color role for --fp-focus-ring-color. Uses that role’s -text colour.
scaleActive0.98Scale on :active press (0–1).

Best Practices

  1. Use the shorthand aliases for the default case. var(--fp-transition-duration) resolves to var(--fp-transition-duration-normal); use the named steps when you want a different speed.

  2. Always use duration tokens, never hardcode 150ms. A theme or a user setting can retime every motion at once; multiply by the motion numbers so the switches reach it.

  3. Use ease-out for most transitions. Elements should arrive quickly and settle — this feels natural. Use ease-in-out for things that move both ways (toggles, slides).

  4. Use --fp-focus-ring-color for focus indicators. It follows the configured colour role and the theme. Don’t hardcode --fp-primary-9.

  5. Test every level. Set --fp-transitions and --fp-animations to reduced and none on :root, and emulate prefers-reduced-motion: reduce (Chrome DevTools: Rendering panel → Emulate CSS media feature).

  6. Active scale (0.98) should be subtle. The press effect should feel tactile, not dramatic. Don’t change this to values below 0.95.

  7. Focus rings must be visible on all interactive elements. Use --fp-focus-ring-width, --fp-focus-ring-offset, and --fp-focus-ring-color consistently. Never set outline: none without a replacement.