Dialog content inside of overlay? #345
-
Centering the dialog content would be much easier if it could be a child of the dialog overlay (since you could just flex center it). Here's a demo of where the current system falls a bit short: The border shows where the So just curious if there is a specific reason these are rendered separately, really excited about this library! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
Hey @jescowuester! Super interesting that you are pointing that out. We did think about this originally but decided not to do that because it complicates things like animating the overlay and the content separately (because for example if you're fading the overlay, your content would also be part of that fade because it's inside). That said, we intended it in a way that would be possible to do both, because there's no reason you couldn't nest if you don't care about that animation/opacity issue with the overlay as a container. But it seems since we added more and more functionality, we did put both the overlay and the content inside a portal each so that they stack properly without needing z-index trickery. The problem with that is that now even if you were to nest your content inside the overlay, they would still both be appended as separate nodes. One thing could consider doing to allow your use case would be to add a Does that make sense? Would it help? |
Beta Was this translation helpful? Give feedback.
-
Btw, sorry I didn't get to your question earlier, not sure why but GitHub didn't notify me of it. |
Beta Was this translation helpful? Give feedback.
-
@benoitgrelard coming back to this one since I need to build some Dialogs that are larger than the viewport. For those I need to be able to scroll the overlay (with the modal inside it). This time I couldn't figure out a way to make this work without nesting the content inside the overlay. |
Beta Was this translation helpful? Give feedback.
Hey @jescowuester!
Super interesting that you are pointing that out.
We did think about this originally but decided not to do that because it complicates things like animating the overlay and the content separately (because for example if you're fading the overlay, your content would also be part of that fade because it's inside).
That said, we intended it in a way that would be possible to do both, because there's no reason you couldn't nest if you don't care about that animation/opacity issue with the overlay as a container.
But it seems since we added more and more functionality, we did put both the overlay and the content inside a portal each so that they stack properly without needin…