-sd-animation: sd-fadeIn; –sd-duration: 0ms; –sd-easing: ease-in;
The CSS-like line ”-sd-animation: sd-fadeIn; –sd-duration: 0ms; –sd-easing: ease-in;” reads like a compact, custom-property-driven animation directive used by a design system or component library. Below is a concise article explaining what it means, when you might use it, and how to implement the behavior it implies.
What this declaration expresses
- -sd-animation: sd-fadeIn; — Assigns a named animation (sd-fadeIn) to the element. The vendor-like prefix (-sd-) suggests this belongs to a scoped design system or framework that parses custom properties for component behavior.
- –sd-duration: 0ms; — A CSS custom property controlling animation duration; set to 0ms here to force the animation to apply instantly (no visible transition).
- –sd-easing: ease-in; — A CSS custom property specifying the timing function for the animation easing curve.
Together, these properties let authors toggle animation type, timing, and easing from markup or component props without editing raw keyframes.
Why use custom properties and prefixed names
- Theming & Overrides: Custom properties make it easy to override animation timing across components or themes.
- Runtime control: JavaScript or component props can update CSS variables to change animations dynamically.
- Encapsulation: A prefixed name (like -sd-) reduces the chance of collisions with other CSS variables and signals that the property is part of a system API.
- Graceful defaults: Components can provide sensible defaults while allowing consumers to tweak specifics.
Typical implementation pattern
- Define the keyframes and default variables in a component stylesheet:
css
:root {–sd-duration: 300ms; –sd-easing: ease;}
/* named keyframes used by the design system /@keyframes sd-fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); }}
/ utility that applies the chosen animation */[data-sd-animated] { animation-name: var(-sd-animation, none); animation-duration: var(–sd-duration); animation-timing-function: var(–sd-easing); animation-fill-mode: both;}
- Use on elements; override duration/easing as needed:
html
<div data-sd-animated style=”-sd-animation: sd-fadeIn; –sd-duration: 0ms; –sd-easing: ease-in;”> Instant visible content (no fade)</div>
<div data-sd-animated style=”-sd-animation: sd-fadeIn; –sd-duration: 250ms; –sd-easing: cubic-bezier(.2,.9,.2,1);”> Smooth fade-in</div>
When setting duration to 0ms is appropriate
- Accessibility & reduced-motion: Respect user preferences or provide a reduced-motion variant by setting duration to 0ms.
- Conditional rendering: When you need the end-state instantly (e.g., server-rendered content that must not animate on initial load).
-
Leave a Reply