Understanding `-sd-animation: sd-fadeIn; –sd-duration: 0ms; –sd-easing: ease-in;
This short CSS-like snippet sets three custom properties and a custom animation shorthand used by some design systems or component libraries:
- -sd-animation: a custom property naming an animation preset (
sd-fadeIn). - –sd-duration: the animation duration (
0msdisables visible motion). - –sd-easing: the timing function (
ease-infor accelerating start).
What it does
When applied to an element, the snippet indicates the element should use the sd-fadeIn animation preset, but with zero duration so no visible fade occurs; the easing is defined as ease-in (only relevant if duration > 0).
Typical usage pattern
Libraries often define animation presets and read these properties to apply animations. Example behavior (conceptual):
- A component checks
-sd-animationto choose keyframes namedsd-fadeIn. - It reads
–sd-durationand–sd-easingto build theanimationshorthand:animation: sd-fadeIn var(–sd-duration) var(–sd-easing) both;.
Example: turning this into working CSS
Assuming you want a real fade-in, set a nonzero duration and define the keyframes:
:root {–sd-duration: 300ms; –sd-easing: ease-in; -sd-animation: sd-fadeIn;}
@keyframes sd-fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); }}
.fade-in { animation: var(-sd-animation) var(–sd-duration) var(–sd-easing) both; /* fallback */ will-change: opacity, transform;}
When to use a zero duration
- To disable animations across a UI quickly (accessibility preference or performance mode).
- To test layout/state without motion while keeping animation hooks in place.
Accessibility note
Respect users’ reduced-motion preferences. Detect via @media (prefers-reduced-motion: reduce) and set –sd-duration: 0ms there to avoid unwanted motion.
Quick checklist for implementers
- Define matching keyframes for any animation name used in
-sd-animation. - Ensure components read these custom properties when setting the
animationshorthand. - Set sensible defaults and provide a reduced-motion override.
If you want, I can convert this into a small component example (React or Web Component) that reads these vars and applies animations.
Leave a Reply