Skip to content

Animation

Keep native transitions, interruption behavior and reduced-motion preferences intact.

Native state

Component style maps respond to native state attributes such as open, closed, starting and ending states. Keep these attributes and the native part's lifecycle when composing an overlay. Hiding the element with an unrelated timer can interrupt dismissal and focus restoration.

Custom transitions

Add a transition through xstyle only when the component exposes the state you need. Prefer opacity and transforms for visual movement; test rapid open/close interruptions and avoid animating layout on every pointer movement.

Inspect the component's StyleX source and actual API before overriding a transition. Families do not share a universal animation prop.

Reduced motion

Respect the user's motion preference in custom application styles:

@media (prefers-reduced-motion: reduce) {
  .project-transition {
    animation: none;
    transition: none;
  }
}

This application rule does not replace the native component's state or completion handling. Test focus restoration and dismissal with reduced motion enabled.

Elastic controls

Primary Tabs support elastic (enabled by default). Use <Tabs elastic={false}> to disable list press feedback while retaining indicator drag and lift. Secondary Tabs do not use this feedback.

For custom controls, pair the public hook with its presentation variables:

import { useElasticRef } from "@lenso/glass/react";
import * as stylex from "@stylexjs/stylex";

const styles = stylex.create({
  elastic: {
    scale: "var(--lg-press-scale, 1 1)",
    translate: "var(--lg-press-translate, 0px 0px)",
  },
});

function ElasticButton() {
  const ref = useElasticRef<HTMLButtonElement>(undefined);
  return (
    <button ref={ref} {...stylex.props(styles.elastic)}>
      Press me
    </button>
  );
}

The hook manages pointer tracking, spring return and cleanup. Native semantics, focus and keyboard activation remain your component’s responsibility. It does not add glass rendering; use your own surface. Reduced motion follows the shared motion preference.