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.
12345{ "rules": { "systomic/prefer-transition": "warn" }}See the difference
className="data-[state=closed]:animate-out"className="transition-transform data-[state=closed]:translate-y-full"What doesn't work
Oxlint
4 findings1234567891011declare function cn(...classes: unknown[]): string;
export function Drawer({ open }: { open: boolean }) { return ( <> <aside className="data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:slide-out-to-bottom" data-state={open ? "open" : "closed"} /> <aside className={cn("fixed inset-x-0 bottom-0", open && "animate-drawer-in")} /> <aside style={{ animation: open ? "drawer-in 500ms" : "drawer-out 500ms" }} /> </> );}systomic/prefer-transition data-[state=open]:animate-in runs keyframes when data-[state=open] 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.
systomic/prefer-transition 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.
systomic/prefer-transition animate-drawer-in runs keyframes when open 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.
systomic/prefer-transition animation: open ? "drawer-in 500ms" : "drawer-out 500ms" runs keyframes when open 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.
Stylelint
2 findings123456.drawer[data-state="open"] { animation: drawer-in 500ms ease-out;}.drawer[data-state="closed"] { animation: drawer-out 500ms ease-in;}systomic/prefer-transition animation: drawer-in 500ms ease-out runs keyframes when [data-state="open"] 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.
systomic/prefer-transition animation: drawer-out 500ms ease-in 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 works
No findingsOxlint
123456789101112export function Drawer({ open, loading }: { open: boolean; loading: boolean }) { return ( <> {/* A transition starts from where the drawer is, so closing it halfway reverses it. */} <aside className="transition-transform duration-500 data-[state=closed]:translate-y-full" data-state={open ? "open" : "closed"} /> <aside style={{ transition: "translate 500ms", translate: open ? "0" : "0 100%" }} /> {/* Keyframes that only play on mount, and looping ones, are fine. */} <div className="animate-in fade-in" /> <div className={loading ? "animate-spin" : undefined} /> </> );}Stylelint
123456789.drawer { transition: translate 500ms cubic-bezier(0.32, 0.72, 0, 1);}.drawer[data-state="closed"] { translate: 0 100%;}.spinner[data-state="loading"] { animation: spin 1s linear infinite;}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.
1234567// Closing it halfway makes it jump.<SheetContent className="data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:slide-out-to-bottom" /><aside className={open ? "animate-drawer-in" : "animate-drawer-out"} />
// Closing it halfway reverses it from where it is.<aside className="transition-transform duration-500 data-[state=closed]:translate-y-full" /><aside style={{ transition: "translate 500ms", translate: open ? "0" : "0 100%" }} />
data-[state=closed]:animate-outruns keyframes whendata-[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 behindgroup-/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, soopen && enteris reported onenter. - Inline styles / StyleX:
animation/animationNamepicked 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-inon an element that mounts): they play once, nothing interrupts them. - Native open states (
open:,[open],:popover-open):<dialog>,<details>and popovers go fromdisplay: noneto shown and hide at once, so their animations play on mount. - Looping animations:
animate-spin,animate-ping,animate-pulse,animate-bounce,infinite(also inanimate-[…]), andanimate-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 inanimation-duration: theanimation-iteration-countand shorthands that win in the style object or rule, per animation, sodrawer-in 500ms, shimmer 2s infiniteis still reported fordrawer-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.