systomic

Prefer transition

Close a drawer while it is still opening and a keyframe animation snaps it back to its first frame. A transition starts from where the drawer is right now, so it simply turns around.

  • SuggestionIn suggestions.json: good practice. It only ever warns.
  • WarningShows in the editor and in CI output, but doesn't fail the run (unless you pass --deny-warnings).
  • StylelintThe same check runs on .css and .scss files through the Stylelint plugin.

See the difference

Before
Keyframes
className="data-[state=closed]:animate-out"
After
Transition
className="transition-transform data-[state=closed]:translate-y-full"

What doesn't work

Oxlint

4 findings

Stylelint

2 findings

What works

No findings

Oxlint

Stylelint

Details

Keyframe animations always start from their first frame, not from where the element is. A transition starts from where the element is right now. So when someone closes a drawer while it is still opening, a keyframe animation snaps it back to fully open and slides it out from there, while a transition just reverses. Use transitions for anything people can interrupt: drawers, sheets, dialogs, accordions, menus.

data-[state=closed]:animate-out runs keyframes when data-[state=closed] changes. Keyframes always start from their first frame, so changing it mid-animation (closing a drawer while it opens) makes the element jump. Consider a transition: it starts from where the element is.

What is checked

Keyframes that play on a state change: an open / closed / expanded state, or a condition in the code about one. Other data-state values (active, checked, loading) aren’t an open / closed state and aren’t reported. A condition in the code counts when a name in it ends in a state (open, closed, expanded, collapsed and their -ing forms: isOpen, sheetOpen, state === "closed"). Settings, callbacks and timestamps (defaultOpen, canOpen, onOpen, openDelay, closedAt) don’t change while it animates, so they don’t count, and reducedMotion ? "" : "animate-in", isMobile ? … : …, showToast && … or closeOnEscape && … isn’t reported. Nested conditions are followed: reducedMotion ? "none" : open ? "in" : "out" is reported for open.

  • Tailwind: animate-* (animate-in, animate-out, animate-accordion-down, animate-[…], animate-(…)) with a state variant (data-[state=open]: / closed / delayed-open …, data-open:, data-closed:, data-[open]:, aria-expanded:, also behind group- / peer-), or picked by a state condition (open ? "animate-in" : "animate-out", cn(isExpanded && "animate-in"), cn({ "animate-in": sheetOpen })), also through variables: a shared string (const enter = "animate-in") is checked where it’s used, so open && enter is reported on enter.
  • Inline styles / StyleX: animation / animationName picked by a state condition (animation: open ? "in 300ms" : "out 300ms", style={open ? { … } : { … }}), or under a state condition in StyleX (":where([data-state=closed])": slideOut).

Not reported:

  • Keyframes without a state (animate-in fade-in on an element that mounts): they play once, nothing interrupts them.
  • Native open states (open:, [open], :popover-open): <dialog>, <details> and popovers go from display: none to shown and hide at once, so their animations play on mount.
  • Looping animations: animate-spin, animate-ping, animate-pulse, animate-bounce, infinite (also in animate-[…]), and animate-none / animation: none. Loop modifiers count too (animate-infinite, repeat-infinite), and modifier classes (animate-duration-300, animate-delay-100) aren’t keyframes. Loops are read like in animation-duration: the animation-iteration-count and shorthands that win in the style object or rule, per animation, so drawer-in 500ms, shimmer 2s infinite is still reported for drawer-in.
  • Motion (animate, variants): it already animates from the current value when the target changes.

A one-off effect on a state change that doesn’t move between an open and a closed position (a nudge or shake when something expands) is fine as keyframes: disable the rule on that line.

It’s a suggestion, without a fix: moving to a transition means restating the open and closed styles.

Radix

Radix waits for an exit animation before it unmounts closed content, but not for an exit transition. With transitions, keep the content mounted (forceMount) and style the closed state with data-[state=closed]:, or use a library that waits for transitions (Base UI with data-[starting-style] / data-[ending-style], Vaul). Add the files to ignore if you keep keyframes.

Option Default
ignore []: file globs relative to the package root
attributes, callees, styleAttributes see styling

Stylelint

For .css / .scss files (see Stylelint): animation / animation-name in a rule whose selector (or an enclosing one, also across @media) has a state ([data-state="open"] / closed …, [data-open], [aria-expanded="true"], .is-open, .open, .expanded), and @apply animate-* with a state variant or in such a rule. Looping animations and none are skipped. Severity warning, no autofix.

See Styling for how classes, inline styles, StyleX and stylesheets are read.

Esc