Skip to content

Animated Entrance

Define a custom @keyframes entrance, reference it via --animation, and disable it gracefully with prefers-reduced-motion.

A polished entrance animation makes the banner feel native to your site rather than a jarring popup. This recipe defines a slide-up-fade-in animation, wires it to the banner via a token, and includes the mandatory prefers-reduced-motion override so users who have opted out of motion in their OS settings see an instant appearance instead.

custom.css
/* ── Entrance animation ────────────────────────────────── */
/* 1. Define the keyframes */
@keyframes ag-slide-up {
from {
opacity: 0;
transform: translateY(20px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
/* 2. Apply to the banner root */
.ag-banner {
/* Token used by the runtime to animate the entrance */
--animation: ag-slide-up 0.35s cubic-bezier(0.22, 1, 0.36, 1) both;
/* Apply the animation */
animation: var(--animation);
}
/* 3. Respect the user's motion preference — mandatory */
@media (prefers-reduced-motion: reduce) {
.ag-banner {
--animation: none;
animation: none;
}
}
classic · dialog · center
  • @keyframes ag-slide-up defines the animation: the banner starts 20 px below its final position and fully transparent, then moves up and fades in.
  • cubic-bezier(0.22, 1, 0.36, 1) is an ease-out curve — fast start, soft landing. It feels snappy without being abrupt.
  • animation: var(--animation) applies the animation. Using the token variable means the runtime can override it from server-side configuration in a future version.
  • fill-mode: both (the both keyword in the shorthand) holds the final frame — without it, the banner would snap back to its pre-animation opacity after the animation ends.
  • prefers-reduced-motion: reduce — when this media query matches, both --animation and the animation property are set to none. This disables the animation entirely without hiding or repositioning the banner.

Fade only (no motion):

@keyframes ag-fade-in {
from { opacity: 0; }
to { opacity: 1; }
}
.ag-banner {
animation: ag-fade-in 0.3s ease both;
}
@media (prefers-reduced-motion: reduce) {
.ag-banner { animation: none; }
}

Slide in from the right (for bar layout at bottom-right):

@keyframes ag-slide-left {
from { opacity: 0; transform: translateX(40px); }
to { opacity: 1; transform: translateX(0); }
}
.ag-banner {
animation: ag-slide-left 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@media (prefers-reduced-motion: reduce) {
.ag-banner { animation: none; }
}

Scale-up pop (floating layout):

@keyframes ag-scale-up {
from { opacity: 0; transform: scale(0.92); }
to { opacity: 1; transform: scale(1); }
}
.ag-banner {
animation: ag-scale-up 0.28s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
@media (prefers-reduced-motion: reduce) {
.ag-banner { animation: none; }
}

The animation applies only to the entrance — it does not affect button state, visibility, or any GDPR-required element. The banner appears immediately in terms of DOM presence; the animation is purely visual layering.