-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: Cannot properly center Headless UI Dialog/Modal due to scrollbar padding #839
Comments
to manually clear out the |
Hey! Thank you for your bug report! The reason we apply a One thing you can do is to use the If you then switch your Hope this helps! |
|
I fixed it seamlessly (without any movement/shifting) by putting
edit: i realized this depends on the padding of your scrollbar, may be different between browsers but you'll have to experiment |
What package within Headless UI are you using?
@headlessui/react
What version of that package are you using?
1.4.1
What browser are you using?
Chrome
Reproduction repository
https://github.com/domdomegg/headless-ui-dialog-centering
Describe your issue
When a Dialog/Modal is opened, if the scrollbar was visible at the time of opening additional padding is added to make up for the scrollbar disappearing to avoid the page jumping around.
However, this padding is of variable width (the width of the scrollbar) and it's hard to predict when it appears. That makes centering an element relative to the original page difficult as generally the dialog uses position: fixed (as per the guide in the docs on styling).
The text was updated successfully, but these errors were encountered: