Closed ayadav42 closed 1 month ago
You can use the container
prop for it! It's not well documented, but just passing a ref into Drawer.Root
should be enough! :)
Documentation will come soon.
Thanks for responding!!
I tried the 'container' prop, I even traced that the container reference I'm passing is reaching Drawer.Root
or not, but for some reason the drawer attaches itself to main document body when it pops up rather than the passed container. At which point I thought, maybe, passing the container is not supposed to achieve what I want, which is to limit the width. I think appending to the root body html element is the default behavior of React Dialog and is inherited as it is. I may be entirely mistaken though.
If there's an example where the width of the drawer limits itself to the passed container's width, I would appreciate it if you could please share. If not, I am happy to share a simple reproduction of the problem.
Thanks for creating this wonderful and clean widget though.
Can you provide a demo of what you tried?
I created a simple next js app with a single page here -> Vaul-Drawer-Demo.
Here is the codesandbox.
I don't know what I'm doing wrong but what I'm trying to achieve is make the drawer limit its width to the main panel and not cross over into the side panel. Below is a screenshot from the above sandbox.
Please let me know if you need anything else.
bumping the message above just in case.
This should do exactly what you want @ayadav42 : https://codesandbox.io/p/github/ayadav42/vaul-drawer-demo/csb-yqhq53/draft/elastic-agnesi?import=true
absolute
in the point belowfixed
makes an element relative to the viewport (browser window). i replaced it with absolute
, that combined with relative
in the parent makes it a bottom drawer contained to the element you wantAdding my findings about this feature (rendering the drawer into a different element)
position:relative
+ the container
prop on Vaul.Root
works.However, there's some confusion by the fact that the Vaul.Portal
also has a (undocumented) container
prop.
It's unclear when we should use one vs the other, or both, or removing the Portal altogether...
Would love some more info / examples on this
The drawer works great. It would be nice if the drawer could contain itself within a container. For example in a react component such as the following:
The drawer should attach itself to the parent div 'main-panel' and align its position and adjust its dimensions. It should pop up from the bottom left of the div and not the main html body. It's width should also be restricted to the width of the parent div. Basically, with respect to the above example, it should not cover 'SearchPanel'.