Understanding ”-sd-animation: sd-fadeIn; –sd-duration: 250ms; –sd-easing: ease-in;”
This short CSS snippet applies a custom animation using CSS custom properties and a named animation token. Here’s what each part does:
- -sd-animation: sd-fadeIn;
- Assigns a design-system-specific animation identifier (sd-fadeIn). This likely maps to a keyframe animation defined elsewhere in the stylesheet or design system.
- –sd-duration: 250ms;
- Sets a custom property for animation duration to 250 milliseconds. Components or utility rules can read this to control timing.
- –sd-easing: ease-in;
- Sets the timing function via a custom property, using the built-in ease-in curve.
How it works in practice
Design systems often centralize animation definitions and allow components to opt in by setting a single token. The token name (-sd-animation) suggests a prefixed property intended for internal use, while the CSS variables (–sd-) let authors override timing without changing the core animation.
Example flow:
- A global stylesheet defines:
- @keyframes sd-fadeIn { from { opacity: 0 } to { opacity: 1 } }
- A utility rule that reads -sd-animation and applies the corresponding keyframes, using –sd-duration and –sd-easing for animation properties.
- A component sets the three properties shown to enable a 250ms fade-in that eases in.
Example implementation
css
:root {–sd-duration: 200ms; –sd-easing: ease;}
@keyframes sd-fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); }}
.sd-animated { / hypothetical engine picks this up / animation-name: var(–sd-animation-name, none); animation-duration: var(–sd-duration); animation-timing-function: var(–sd-easing); animation-fill-mode: both;}
/ a utility mapping token to actual name /[data-sd-animation=“sd-fadeIn”] { –sd-animation-name: sd-fadeIn;}
Best practices
- Prefer CSS custom properties for duration and easing so tokens are reusable and themeable.
- Keep durations short (100–300ms) for subtle UI transitions; longer for emphasis.
- Use easing curves that match the motion intent: ease-in for entering content, ease-out for exiting, and custom cubic-beziers for more nuanced motion.
- Define animations centrally to ensure consistency across components.
Accessibility considerations
- Respect user preferences: add a media query to disable or reduce motion when prefers-reduced-motion is set.
css
@media (prefers-reduced-motion: reduce) { .sd-animated { animation: none !important; }}
When to use this pattern
- In component libraries or design systems that want consistent, overridable motion.
- When you need a compact way for authors to opt into predefined animations while allowing local timing overrides
This snippet is a concise, theme-friendly way to enable a 250ms fade-in with ease-in timing while keeping animation details centralized and customizable.*
Leave a Reply