Color spaces
Interpolating a color means walking a straight line between two points - but which space you draw that line in decides what the midpoints look like. In sRGB the channels are mixed numerically, which is why two distant colors pass through a dark, muddy middle on the way. OKLab is built so that equal steps look like equal steps: the lightness travels evenly from one end to the other, so the same journey stays clean and bright the whole way across. Opposite hues still meet near grey in the middle - in any space a straight line between them crosses it - but a light grey, not a dark one.
sRGB and OKLab side by side
sRGB is the default, matching Framer Motion. Opt into the perceptual space per transition
with colorSpace: BmotionColorSpace.Oklab, or for a whole subtree with
<BmotionConfig ColorSpace="BmotionColorSpace.Oklab">. The pairs below run the
same transition over the same 1.6 s - watch the middle of each run, not the endpoints,
which are identical by definition.
For a whole subtree
<BmotionConfig ColorSpace="BmotionColorSpace.Oklab"> sets the space for every colour
animation inside it that doesn't choose its own - colour keyframes included, so a palette cycle passes
clean mid-points at every step. A transition that sets its own colorSpace still wins inside
it, so one exception needs no second config. Both orbs below cycle through the same four stops on the
same 4.5 s loop; only the right one sits inside the config.
When it matters
Not every transition needs it. The two colors have to be far enough apart for the midpoint to be visible at all, so the difference is obvious on opposites - blue to yellow, red to green - and invisible between two neighbouring blues. The cost is a per-frame conversion, so the sensible default is what Bmotion does: sRGB unless you ask, and OKLab where the midpoints are actually on screen long enough to be seen.
- Reach for OKLab when a slow transition crosses the color wheel, or when a hue animates through a keyframe palette.
- Leave it at sRGB for short state changes, hover tints, and any pair of nearby colors.
- Set it globally on
BmotionConfigwhen a whole surface should behave consistently rather than deciding per animation.