On this page
  1. Custom Properties & Animation
  2. Contents
  3. CSS Custom Properties (--var)
  4. Transitions, Transforms & Motion Preferences

Custom Properties & Animation

Prev: Typography & Color | Up: properties | Next: functions
Rel: Keyframes, Fonts & Entry Animations, Reflow, Repaint & Performance
Ref: MDN Web Docs — Using CSS Custom Properties
Tags: #public #web #css #properties #animation


Contents


CSS Custom Properties (--var)

Custom properties participate in the cascade and inheritance at runtime and can be read or updated from JavaScript via el.style.setProperty("--accent", ...).

:root {
  --space-md: 1rem;
  --surface: oklch(98% 0.005 260);
}
.card {
  padding: var(--space-md);
  background: var(--surface);
}

Transitions, Transforms & Motion Preferences

Animate compositor-friendly properties (transform, opacity) instead of layout properties (top, width, margin) to stay at 60+ fps, and always respect prefers-reduced-motion:

.btn {
  transition: transform 150ms ease, opacity 150ms ease;
}
.btn:hover {
  transform: translateY(-1px);
}
@media (prefers-reduced-motion: reduce) {
  .btn { transition: none; }
}

Linked from

Related notes