Hover✨ Premium

Color Shift

Background shifts from indigo to violet and the element lifts slightly (translateY -5 px) on hover in 0.5s — color + transform transition, pure CSS.

CSSColor

Updated

This effect is part of Effect.Labs — 840 vanilla effects, some free, some premium. Hover has 48 effects, including 5 free. Explore the category →

3 usage examples

Legal glossary link — knowledge base for a notary practice — Color Shift example 1

① Legal glossary link — knowledge base for a notary practice

WhenClickable terms list (emphyteutic lease, bare ownership, usufruct…); each term changes background on hover.
WhyA pure colour change is the most restrained state feedback; in a long-reading context, no animation is appropriate.
Settings320×44 px list items; indigo base, end colour adjusted (bordeaux for a notary practice); targets within the capture ellipse.
Language switcher on a room-booking site — hotel chain intranet — Color Shift example 2

② Language switcher on a room-booking site — hotel chain intranet

WhenLanguage selector (FR, EN, DE, ES) as text buttons; on hover the button changes colour.
WhyA simple, universal colour change works even with system animations disabled.
Settings60×40 px inline buttons; indigo at rest, violet on hover; 6 px corners; short text (2–3 letters).
Component filter tag — BOM search interface for an electronics database — Color Shift example 3

③ Component filter tag — BOM search interface for an electronics database

WhenFilter tags (voltage, current, package, brand); each tag changes background on hover to signal possible selection.
WhyA colour change is lightweight and doesn't disrupt reading in a dense data table.
Settings100×32 px rounded tags; indigo base, violet hover; white text; targets on the capture ellipse.

How it works

The .fx-0349-root wrapper centres a 200 px button. At rest, the background is indigo (#6366f1). On hover, background: #d946ef (violet-pink) and transform: translateY(-5px) apply simultaneously over 0.5 s. The transition covers background-color, color and transform. The colour change (indigo → violet) is the main effect; the slight upward shift reinforces the hover impression without strongly displacing the element in the layout.

No pseudo-element, no gradient on the animation — background-color itself transitions from one colour to the other. :focus-visible triggers the same state. Under reduced motion, the transition is removed (instant change) and translateY is suppressed, leaving only the colour change visible.

Accessibility

  • Reduced motion: under prefers-reduced-motion: reduce, all transitions are disabled and the transform is suppressed on hover. The colour change (indigo → violet) remains active instantly — state feedback guaranteed.
  • Keyboard: the element is a natively focusable <button>. :focus-visible triggers the colour change and lift, with a 2 px white outline for keyboard focus.
  • Contrast: violet-pink (#d946ef) on a white background may be insufficient (ratio < 3:1). Check with a WCAG contrast tool if your brand changes the colours.
  • Touch: a tap activates the CSS hover state on most mobile browsers. The effect clears on the next focus change.

Browser compatibility

Pure CSS. Properties: background-color, color, transform: translateY, transition, :focus-visible. Verified in Chromium and Firefox: colour change and lift visible, two independent copies, 0 errors.

Chrome 86+✓ Full (measured)
Firefox 85+✓ Full (measured)
Safari 15.4+✓ Full (:focus-visible)
Edge 86+✓ Full (Chromium engine)
Mobile iOS 15.4+✓ Full
Android Chrome 86+✓ Full (measured)

Without :focus-visible (before 2021), keyboard focus does not trigger the colour change.

The code

HTML structure to paste into your page (the CSS + JS come with your purchase):

index.html — structure
<div class="fx-0349-root">
  <button class="csh-box csh-shift" type="button">
    <span>Your text</span>
  </button>
</div>

One-time payment, no subscription — the code is yours forever

Customize

Options passed to the API or data-* attributes:

Option / propertyDefaultEffect
Resting colour (CSS — background: #6366f1) indigo Replace with your brand's primary colour. Ensure white text is readable (WCAG ratio ≥ 4.5:1).
Hover colour (CSS — background: #d946ef) violet-pink Choose a colour that contrasts with the hover text. For a subtler effect, use a slightly darker shade of the resting colour.
Vertical lift (CSS — translateY(-5px)) -5 px 0 removes the lift, leaving only the colour change. -10 px is more pronounced but may visually misalign in a tight grid.
Duration (CSS — 0.5s) 0.5 s 0.2 s is more responsive; 0.8 s gives a smoother transition.
Targeted transition (CSS — background-color 0.5s, color 0.5s, transform 0.5s) 3 properties Remove transform 0.5s to disable the lift while keeping the colour animation.

FAQ

Remove transform: translateY(-5px) from the :hover/:focus-visible rule and remove transform 0.5s from the transition. Keep only background-color 0.5s, color 0.5s.
CSS cannot animate background-image (gradient) directly. Two approaches: a ::before pseudo-element with the gradient at opacity: 0 transitioned to 1 on hover; or background-size: 200% with position animation (see fx-0344).
translateY does not affect document flow — the reserved space stays the same. If the element visually overlaps a neighbour, add z-index: 1 to the :hover/:focus-visible state and isolation: isolate on the parent.