These look like custom CSS custom properties and a shorthand utility for an animation. Brief breakdown and usage:
What they are
- –sd-animation: sd-fadeIn; — a custom property naming which animation to apply (here a keyframe set named “sd-fadeIn”).
- –sd-duration: 250ms; — duration of the animation.
- –sd-easing: ease-in; — timing function (easing) for the animation.
Typical implementation pattern
- Define keyframes for the named animation:
css
@keyframes sd-fadeIn {from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); }}
- Use the custom properties in a rule (shorthand utility):
css
.element { /* fallbacks if needed / –sd-animation: sd-fadeIn; –sd-duration: 250ms; –sd-easing: ease-in;
animation-name: var(–sd-animation); animation-duration: var(–sd-duration); animation-timing-function: var(–sd-easing); animation-fill-mode: both;}
- Variant: an authoring utility that switches animations via the property:
css
/ different animation option /:root { –sd-duration: 250ms; –sd-easing: ease-in; }
.fade-in { –sd-animation: sd-fadeIn; }.slide-left { –sd-animation: sd-slideLeft; }
/ components use the vars */.card { animation-name: var(–sd-animation); animation-duration: var(–sd-duration); animation-timing-function: var(–sd-easing);}
Notes and best practices
- Provide sensible fallbacks for browsers that don’t support CSS variables.
- Include animation-fill-mode (usually both or forwards) so the end state persists.
- Use reduced-motion media query to respect user preferences:
css
@media (prefers-reduced-motion: reduce) { .element { animation: none; }}
That’s the concise explanation and example usage.
Leave a Reply