-sd-animation: sd-fadeIn; –sd-duration: 250ms; –sd-easing: ease-in;
This article explains the meaning, usage, and best practices for the CSS custom properties shown in the title: -sd-animation: sd-fadeIn; –sd-duration: 250ms; –sd-easing: ease-in;. These variables are commonly used to control animations in component libraries or design systems that expose CSS custom properties (variables) for easy theming and runtime adjustments.
What these properties represent
- -sd-animation: sd-fadeIn;
Assigns a named animation preset. In design systems this often maps to a keyframes animation (here, a fade-in effect). The leading hyphen suggests it’s a custom, possibly vendor-like property used internally by a UI kit. - –sd-duration: 250ms;
Sets the animation duration to 250 milliseconds. Short durations like this suit subtle UI transitions (tooltips, small element fades). - –sd-easing: ease-in;
Sets the timing function;ease-inmeans the animation starts slowly and speeds up, making elements appear gently.
How to implement in CSS
Assume a design system exposes -sd-animation as a token; map it to actual animations with CSS variables and utility classes.
Example:
:root {–sd-duration: 250ms; –sd-easing: ease-in;}
/* Define keyframes for sd-fadeIn /@keyframes sd-fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); }}
/ Utility that reads the custom properties */.sd-animated { animation-name: var(–sd-animation, sd-fadeIn); animation-duration: var(–sd-duration, 250ms); animation-timing-function: var(–sd-easing, ease-in); animation-fill-mode: both;}
Usage examples
- Apply to a modal:
<div class=“modal sd-animated” style=”–sd-duration: 300ms;”> Modal content</div>
- Faster hover reveal:
.button { –sd-duration: 180ms;}
When to use these values
- Use 250ms for quick but noticeable transitions (toasts, tooltips, dropdowns).
- Use
ease-infor elements entering the view; preferease-outorcubic-bezier()for exits or more natural motion. - Combine with transform (translateY/scale) and opacity for smoother perception.
Accessibility considerations
- Respect prefers-reduced-motion: disable or reduce durations when users request reduced motion.
@media (prefers-reduced-motion: reduce) { .sd-animated { animation: none; transition: none; }}
Tips and best practices
- Keep durations consistent across similar UI patterns.
- Use custom properties for theming and runtime overrides.
- Use descriptive animation names (sd-fadeIn, sd-slideUp) and document them.
Conclusion
-sd-animation: sd-fadeIn; –sd-duration: 250ms; –sd-easing: ease-in; is a compact way to control a fade-in animation via CSS custom properties. It provides flexibility for theming and runtime adjustments while keeping animation behavior consistent across a design system.
Leave a Reply