Article: ”-sd-animation: sd-fadeIn; –sd-duration: 250ms; –sd-easing: ease-in;”
What this snippet is
This is a set of custom CSS custom properties (CSS variables) used to control a small animation system. It defines:
- –sd-animation: the animation name (here
sd-fadeIn). - –sd-duration: animation length (
250ms). - –sd-easing: timing function (
ease-in).
How it works
A stylesheet or component reads these variables and applies a matching animation. Example behavior:
- The element uses the
sd-fadeInkeyframes. - The animation runs for 250 milliseconds.
- The motion follows an
ease-incurve (starts slow, then accelerates).
Example implementation
css
:root {–sd-animation: sd-fadeIn; –sd-duration: 250ms; –sd-easing: ease-in;}
.animated { animation-name: var(–sd-animation); animation-duration: var(–sd-duration); animation-timing-function: var(–sd-easing); animation-fill-mode: both;}
/* fade-in keyframes */@keyframes sd-fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); }}
Usage tips
- Change
–sd-durationfor snappier or slower reveals (e.g., 150ms or 400ms). - Swap easing for different feels:
linear,ease-out,cubic-bezier(…). - Combine with
animation-delayto stagger multiple elements. - Use
animation-fill-mode: bothto keep the end state after animation.
Accessibility note
Keep animations short and avoid continuous motion. Respect prefers-reduced-motion by disabling or simplifying animations when the user preference is set:
css
@media (prefers-reduced-motion: reduce) { .animated { animation: none; opacity: 1; transform: none; }}
Conclusion
These CSS variables provide a concise, reusable way to control fade-in animations across components, making it easy to tune timing and easing consistently.
Leave a Reply