-sd-animation: sd-fadeIn; –sd-duration: 0ms; –sd-easing: ease-in;
This article explains the CSS-like custom properties shown in the title, what they do, how and when to use them, and practical examples for implementation.
What these properties represent
- -sd-animation: A custom CSS property intended to select a predefined animation (here,
sd-fadeIn). - –sd-duration: Duration of the animation (
0msin the title, meaning instantaneous). - –sd-easing: The timing function that controls animation pacing (
ease-inhere).
These look like CSS custom properties (CSS variables). They may be used by a framework or component library that reads these variables and applies corresponding animations via standard CSS or JavaScript.
Typical use cases
- Allowing component-level customization of animations without modifying stylesheet code.
- Templating systems where animations are chosen dynamically.
- Theme variables for consistent motion design across an app.
How they might be implemented
- Define the animation keyframes and a mapping from
-sd-animationvalues to actual animation names:
css
@keyframes sd-fadeIn {from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); }}:root { –sd-duration: 200ms; –sd-easing: ease-out;}
- Apply the variables in a component:
css
.component { animation-name: var(–sd-animation, none); animation-duration: var(–sd-duration, 200ms); animation-timing-function: var(–sd-easing, ease-out); animation-fill-mode: both;}
- Override per-instance:
html
<div class=“component” style=”–sd-animation: sd-fadeIn; –sd-duration: 150ms; –sd-easing: ease-in;”></div>
Why –sd-duration: 0ms might be used
- To disable animations conditionally (e.g., reduce motion for accessibility or initial render).
- To create instant state changes while preserving a single code path for animation handling.
Accessibility considerations
- Respect user preference for reduced motion (prefers-reduced-motion).
- Provide sensible default durations and avoid jarring movements.
Example:
css
@media (prefers-reduced-motion: reduce) { .component { animation-duration: 0ms !important; }}
Debugging tips
- Verify the custom property name matches what the framework expects (note leading dash vs double-dash).
- Check cascade/priority—inline styles override external stylesheets.
- Ensure animation keyframes exist and
animation-namereceives the correct value.
Conclusion
Using custom properties like -sd-animation, –sd-duration, and –sd-easing offers flexible, per-component animation control. Ensure correct naming, provide fallbacks, and consider accessibility to make animations smooth and user-friendly.
Leave a Reply