Skip to content

Presets

Most interfaces animate the same dozen things: a modal opening, a toast arriving, a card lifting under the pointer, a list revealing itself on scroll. BmotionPresets packages each one, its transition included, so Preset="BmotionPresets.Modal()" replaces an Initial, an Animate, an Exit and a tuned spring. A preset only fills in what the element leaves unset, so anything you write on the element still wins.

Enter and exit

Each preset sets the element's starting state, its resting state and its exit, so it animates in when it mounts and out when a presence component removes it. Remove them all and add them back to compare.

Fade
Slide
Scale
Pop
Blur
Rotate
Flip

Overlays

Dialogs, drawers, popovers, tooltips and toasts each move in their own way. A drawer slides by its own size whatever that is, a popover grows from the edge facing its trigger, and a tooltip barely moves so it never gets in the way of reading it. Their exits are quicker than their entrances, as they should be.

Disclosure panels

BmotionPresets.Expand() opens an accordion panel to its natural height - height: auto, measured, so the panel follows its content once open - and closes it back to nothing on exit. The button stays outside the animated panel and says whether it is open with aria-expanded; the panel needs overflow: hidden. Under reduced motion the height lands at once and the fade remains.

Hover and press

Gesture presets add an overlay and nothing else, so they combine with whatever the element animates. Press works from the keyboard too: tab to the button and hold Space.

HoverLift
Card
HoverScale
Press

Drawing attention

These play when the element mounts. To play one again, give the element a new @key, which mounts it afresh. Use them sparingly: a shake that says "that password was wrong" helps, and one on every button doesn't.

Pulse
Shake
Wiggle
Jump
Heartbeat

Revealing on scroll, and loading

Reveal fades content in from an edge once part of it is in view, and leaves it there. Spin and Shimmer loop for as long as something is loading. Shimmer sweeps the element's background, so give it a gradient twice its width.

Reveal(from: BmotionEdge.Top)
Reveal(from: BmotionEdge.Right)
Reveal(from: BmotionEdge.Bottom)
Spin
Shimmer

Making them yours

Every factory takes the knobs that matter for it, such as the edge a slide starts from or how far a card lifts. Presets add with +, target by target, and the right-hand side's transition wins. They are records, so with changes a single part, and new BmotionPreset { … } makes one of your own - an app's house entrance, written once and reused everywhere. Set a property on the element and it overrides the preset's.

Fade() + Scale(from: 0.5), on a bouncy spring
Slide(), with the element's own transition
new BmotionPreset { … } · your own
Bmotion 0 el · 0 active ▸
An unhandled error has occurred. Reload 🗙