Skip to content

CSS properties

Transforms and opacity are the properties that animate cheaply, and most of this library is about them. This page is the other half: Bmotion's typed props reach across the whole style surface - typography, spacing, positioning, clipping and backgrounds - the cssVars bag animates CSS custom properties, and the generic css bag animates anything else by name. These are the ones that trigger layout or paint rather than compositing, so they are worth spending deliberately. Each group below toggles on its own.

Typography

letterSpacing, fontSize and lineHeight interpolate like any length.

letterSpacing
BMOTION
fontSize
Scale me
lineHeight
Motion that reads well breathes between its lines.

Spacing

gap animates on a flex/grid container; padding grows a box from the inside; margin pushes it within its track.

gap (flex container)
padding
PAD
margin

Sizing

width and height animate between any two lengths in the same unit. A bare number is pixels - Bm.To(width: 180) writes 180px - and a string passes through as written, so "5rem" or "60%" work too. Resizing makes the browser lay the page out again on every frame, so for an element that only needs to look bigger, scale or a layout animation is cheaper.

width: 40 → 180 (bare numbers are px)
width + height in rem

Positioning

Animate top, left, right and bottom on a positioned element - relatively positioned here, so each offset pushes the box away from the edge it names.

left
top + left
right + bottom, from the far corner

Colours

Every colour property interpolates as a colour rather than as text: backgroundColor and color, borderColor and outlineColor, and on SVG shapes fill and stroke. Hex, rgb(), hsl(), named colours and transparent all mix with each other, and the Color page shows choosing the space they mix in.

color
Colour me
borderColor + outlineColor
fill + stroke (SVG)

Clipping & backgrounds

clipPath, backgroundPosition and backgroundSize interpolate their numeric parts frame by frame.

clipPath
backgroundPosition
backgroundSize

Generic Css escape hatch

The css bag animates any CSS property by name (dash- or camelCase) - the equivalent of motion.dev's animate().

css: word-spacing
the quick fox
css: text-indent
Indented on demand.

CSS custom properties

cssVars writes CSS custom properties (keys must start with --) on the animated element, where they cascade to everything inside it. That is the lever for the things inline styles cannot reach directly: a value used several times in one declaration, a gradient stop, a pseudo-element. One animated variable below drives a glow, a border and an inner ring at once, and none of those three is addressed by name.

cssVars: --glow

Accessibility & safety knobs

These are configured once at registration in Program.cs:

  • Reduced motion - AddBitBmotionServices(o => o.ReducedMotion = BmotionReducedMotionMode.User) respects the OS prefers-reduced-motion everywhere. When reduced, transforms snap while opacity/color still animate.
  • CSS-injection safe mode - o.CssSafeMode = BmotionCssSafeMode.Throw validates string values before they reach inline style (reject ;, }, javascript:, anything that loads a URL such as url(…), …) and the property names of css and cssVars entries, and throws on one that fails; Warn logs it and applies it anyway, and Off, the default, skips the check. Enable it when binding untrusted input.
  • Capabilities - inject BmotionCapabilities to branch on SupportsFrameLoop (false on Blazor Server, where per-frame features degrade).
Bmotion 0 el · 0 active ▸
An unhandled error has occurred. Reload 🗙