Overview
A background-position fill sweep is a state-driven paint transition for buttons, links, chips, and compact navigation targets. The element owns an oversized linear-gradient() background. The resting state positions the accent outside the visible box; the hover or:focus-visible state moves background-position so the accent field sweeps through the target.
When to use it
Use it when the interaction needs a clear filled state but a ripple, tab indicator, or separate overlay would be too much. It works especially well for primary command buttons, inline links that need stronger emphasis, and status chips where the component geometry must remain stable. Avoid it for large panels or constantly looping backgrounds; that turns a compact state cue into a repaint-heavy ambient animation.
How it works
Give the target fixed padding, border, radius, and inline size. Then apply a gradient that is larger than the element via background-size. On state change, move only background-position and, if necessary, text color. The key implementation choice is overscan: a 100% background has nowhere to travel, while a200% or larger background leaves an off-screen color field ready to slide in.
Production gotchas
Do not fake the fill by animating width, padding, border thickness, underline thickness, or line-height. Those properties can push neighboring UI and make the interaction feel unstable. Background-position can also repaint, so keep the target small and avoid running the effect continuously across long lists. If the fill changes text contrast, test the active frame as carefully as the resting frame.
Accessibility
Pair :hover with :focus-visible and preserve a visible outline. The filled state should not be pointer-only. Under prefers-reduced-motion: reduce, remove the transition and pin the filled state so the interaction still communicates selection, emphasis, or focus without a sweep.
References
Implementation depth
This pattern differs from ripples, tab indicators, and gradient text sweeps because the interactive target itself owns the moving background layer. The reusable mechanism is an oversized gradient plus a state change in background-position; the element box, line metrics, and neighboring controls stay fixed.
The production limit is paint budget and input modality. Background-position can repaint the target, so keep it on small controls and avoid continuous loops in dense lists. Pair hover with focus-visible, preserve an outline, and use reduced motion to pin the filled state instead of running a substitute animation.