-sd-animation: sd-fadeIn; –sd-duration: 0ms; –sd-easing: ease-in;
This article explains what the CSS-like custom properties in the title mean, how they’re used, and when to apply them. I’ll assume these are CSS custom properties (CSS variables) used by a component or design system to control animations.
What these properties represent
- -sd-animation: sd-fadeIn;
Sets the named animation or animation preset the component should run. In a design system,sd-fadeInlikely references a predefined keyframe sequence that fades an element from transparent to opaque. - –sd-duration: 0ms;
Controls how long the animation runs.0msmeans the animation duration is zero — effectively instantaneous. This is useful when you want to disable animation while keeping the same CSS contract. - –sd-easing: ease-in;
Defines the timing function for the animation’s progression.ease-incauses the animation to start slowly and speed up toward the end.
Typical implementation patterns
- Define keyframes and a mapping from the custom property to actual animation rules:
css
@keyframes sd-fadeIn {from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); }}
/* Fallback default variables /:root { –sd-animation: sd-fadeIn; –sd-duration: 200ms; –sd-easing: ease-out;}
/ Component uses the variables */.component { animation-name: var(–sd-animation); animation-duration: var(–sd-duration); animation-timing-function: var(–sd-easing); animation-fill-mode: both;}
- Inline or per-instance overrides:
html
<div class=“component” style=”–sd-animation: sd-fadeIn; –sd-duration: 0ms; –sd-easing: ease-in;”> Instant reveal content</div>
Use cases
- Disable animation for accessibility or testing: Setting
–sd-duration: 0msturns off the visual transition while preserving markup and behavior. - Per-component customization: Different elements can share the same CSS but vary animations via these variables.
- Design system consistency: Using semantic animation names (like
sd-fadeIn) keeps animations consistent and replaceable.
Accessibility considerations
- Respect user preferences: prefer
prefers-reduced-motionto set–sd-duration: 0mswhen users request reduced motion.
css
@media (prefers-reduced-motion: reduce) { :root { –sd-duration: 0ms; }}
- Instantaneous changes can be jarring; use 0ms only when necessary (e.g., testing or explicit user choice).
Troubleshooting
- If nothing animates, ensure the named keyframes exist and
animation-nameis correctly assigned from the custom property. - Zero duration yields no visual interpolation—confirm that’s intended.
- Ensure custom property names match (note leading hyphen vs double-hyphen).
Quick checklist before using these values
- Is zero duration intentional (accessibility/testing)? If not, set a nonzero duration.
- Does
sd-fadeInkeyframe exist and include properties you expect (opacity, transform)? - Have you handled reduced-motion preferences?
Example: toggle with CSS variables and JavaScript
js
// Toggle animations on/offconst el = document.querySelector(’.component’);function setAnimations(enabled) { el.style.setProperty(’–sd-duration’, enabled ? ‘200ms’ : ‘0ms’);}
Conclusion: The trio -sd-animation: sd-fadeIn; –sd-duration: 0ms; –sd-easing: ease-in; provides a flexible, design-system-friendly way to control animation behavior per component, with 0ms effectively disabling motion while preserving structure. Use it thoughtfully alongside accessibility settings.
Leave a Reply