API Reference
styleTxn
Batched CSS variable and style writer used by built-in and custom modules.
styleTxn
styleTxn is the runtime’s style write transaction.
Public status
styleTxn is exported by the package root and is valid advanced integration surface.
What it does
It batches:
- CSS custom property writes
- standard style property writes
so modules can write in one controlled mutate phase instead of spamming direct style mutations.
Main methods
begin()setVar(...)setVars(...)setProp(...)setProps(...)commit()cancel()run(fn)setVarDirect(...)
Typical usage
TypeScript
styleTxn.run(() => {
styleTxn.setVar(element, '--progress', 0.5);
styleTxn.setProp(element, 'transform', 'translateY(20px)');
});
Important behavior
- queued writes only work while the transaction is open
run(fn)is the easiest safe formsetVarDirect(...)writes immediately and bypasses batching- numeric CSS custom properties may use Typed OM internally when available
When to use it
Use it when:
- a custom module writes several vars or style props
- you want output to stay aligned with
onMutate(...) - you need deduped writes per element and key
Practical note
If you are inside onMutate(...), styleTxn is usually the correct write primitive.