-sd-animation: sd-fadeIn; –sd-duration: 0ms; –sd-easing: ease-in;
This article explains what the CSS-like properties in the title mean, how they’re used in modern front-end workflows, and practical guidelines for implementing similar animation controls.
What these properties represent
- -sd-animation: a custom CSS property (likely a framework or design-system shorthand) that names an animation — here
sd-fadeIn. - –sd-duration: a CSS custom property specifying the duration of the animation;
0msmeans no visible transition. - –sd-easing: a custom property for the timing function;
ease-inaccelerates the animation from slow to fast.
Although these look like native CSS variables, the leading single dash in -sd-animation suggests a non-standard token used by a specific design system or build tool. Standard custom properties use the –name form; single-dash prefixes are typically reserved for vendor or framework conventions.
How this pattern is used
Many component libraries and design systems expose animation controls via custom properties so developers can configure animations without touching component internals. Typical uses:
- Theme overrides (set durations/easings globally).
- Per-component tweaks (adjust speed or disable animation with
0ms). - Enable runtime theming via JavaScript by setting style properties on elements.
Example (conceptual):
- A component defines an animation
sd-fadeInin its stylesheet. - The component reads
–sd-durationto apply the animation-duration. - Setting
–sd-duration: 0mseffectively disables the visible animation while preserving the final state.
Implementing a fade-in with configurable variables
Use standard custom properties for portability:
:root {–sd-animation-name: sd-fadeIn; –sd-duration: 300ms; –sd-easing: ease-in;}
@keyframes sd-fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); }}
.fade-in { animation-name: var(–sd-animation-name); animation-duration: var(–sd-duration); animation-timing-function: var(–sd-easing); animation-fill-mode: both;}
To disable the animation but keep the end state:
.fade-in.instant { –sd-duration: 0ms;}
Accessibility and performance considerations
- Prefer reduced-motion support: respect the user’s OS preference.
@media (prefers-reduced-motion: reduce) { .fade-in { animation-duration: 0ms; }}
- Avoid animating layout properties; use opacity and transform for smoother performance.
- Keep durations short for micro-interactions (100–300ms); longer durations for larger transitions (300–600ms).
Common pitfalls
- Using
0mswithout fill-mode may revert to the initial state; ensureanimation-fill-mode: bothor set the final properties explicitly. - Conflicting names: ensure the animation name matches the @keyframes identifier.
- Framework naming: single-dash custom names may not be supported by pure CSS — prefer
–when building reusable libraries.
Quick checklist for developers
- Use standard
–custom properties for portability. - Provide sensible defaults in :root or theme tokens.
- Respect prefers-reduced-motion.
- Use opacity/transform for performance.
- Allow disabling via
0mswhile preserving end state with fill-mode.
Conclusion Using configurable animation tokens like –sd-duration and –sd-easing makes components flexible and themeable. If you’re integrating with a design system that uses -sd- prefixes, check its docs — but for cross-project resilience, prefer standard – custom properties and always include accessibility and performance safeguards.
Leave a Reply