Demo, all content is generated
Question

shadcn Select dropdown opens behind my Dialog

Solved · 253 views · asked by yuki_builds · edited

I have a Dialog with a form in it, and the Select inside the form opens its options behind the dialog. You can see them peeking out at the bottom of the modal. The Select outside the dialog works fine.

What I’ve tried

Added z-50 to the Select trigger, asked v0 to fix the layering (it added more z-index classes, still behind).

Comment
Does your DialogContent have a custom z-index class? aiko_n · edited

1 answer

Marked as helpful by the asker
aiko_n · edited

The Select content is rendered in a portal on <body> with z-50. So if your DialogContent or overlay has a higher custom z-index, the options end up underneath. Check your dialog for something like z-[100] or z-[9999]:

grep -rn "z-\[" components/

Best fix: remove the custom z-index from the dialog so both use the shadcn defaults. If you need it (e.g. a sticky header above z-50), raise the select too:

<SelectContent className="z-[110]">

Changing z-index on the trigger does nothing, since the options aren't inside it.

Comment
There was literally z-[999] on the DialogContent. v0 put it there to get over my sticky header. Removed it, gave the header z-40, all fine. yuki_builds · edited
That's the sensible fix. aiko_n · edited
Same with Popover and DropdownMenu, same fix. pixelpaulo · edited