LiquidGlass forces center anchoring via translate(-50%, -50%) making placement difficult; cannot disable via props #20
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
LiquidGlassalways appliesand defaults to
when not provided.
This effectively anchors the component’s center to the given point and makes it hard to position the element in normal document flow or by top-left coordinates.
Passing
globalMousePos={{x:0,y:0}}andmouseOffset={{x:0,y:0}}removes motion, but placement remains “off” due to the enforced center anchoring.Environment
Reproduction
Render
LiquidGlasswithout explicitstyle.top/leftand set mouse props to zeros:The element appears “badly placed” (unexpectedly centered/offset) within the layout.
Even with explicit zero motion, computed styles show:
Expected Behavior
Ability to opt out of the built-in centering so the component can:
-50%translation.Actual Behavior
Component enforces center anchoring:
position: relative,top: 50%,left: 50%when not set.translate(calc(-50% + x), calc(-50% + y))in its inline transform.As a result, the component is difficult to place precisely unless you adopt the center-anchoring model (e.g.,
position: fixed; top: 50%; left: 50%).Code References
Build of transform with
translate(-50%, -50%) + elastic offsets:node_modules/liquid-glass-react/dist/index.js:431Defaulting of position and top/left to 50%:
node_modules/liquid-glass-react/dist/index.js:434-441Workarounds
style={{ position: "fixed", top: "50%", left: "50%" }}to anchor center to viewport.LiquidGlassin a parentposition: relativecontainer and giveLiquidGlassposition: absolute; top: 50%; left: 50%to center within that container.elasticity={0}(but centering remains).Proposed API Improvements
Add a prop to disable internal centering and position management, for example:
managePosition?: boolean(defaulttrue)false, do not set defaultposition/top/left, and omit thetranslate(-50%, -50%)part (apply only elastic translation fromglobalMousePos/mouseOffset).Alternatively:
center?: boolean(defaulttrue) — control the-50%centering behavior explicitly.anchorOrigin?: "center" | "top-left" | { x: string; y: string }— more precise control.Also:
This change would preserve the current default behavior while letting consumers integrate
LiquidGlassinto varied layouts without fighting the enforced center anchoring.Try
@nkzw/liquid-glassinstead.