primitives icon indicating copy to clipboard operation
primitives copied to clipboard

[DropdownMenu] [PopoverMenu] Add Overlay component

Open darrylyeo opened this issue 1 year ago • 8 comments

Feature request

Overview

Implement an Overlay component for DropdownMenu and PopoverMenu (similar to the one found in Dialog) which is displayed behind the popover content.

Examples in other libraries

This would function similarly to the Overlay component found in Dialog and AlertDialog.

Who does this impact? Who is this for?

A stylable overlay would help make the popover content stand out and visually indicate that the user can click outside to dismiss the menu.

darrylyeo avatar Sep 22 '22 00:09 darrylyeo

Hi @darrylyeo, It isn't very common to display menus/popover with overlays behind them. Do you have examples of that in the wild?

If we were to make this happen, they would only be for modal mode, which Popover isn't by default, but DropdownMenu is. The part would be optional regardless I guess.

Thoughts on this @andy-hook?

benoitgrelard avatar Sep 22 '22 07:09 benoitgrelard

It’s not particularly common but I have seen it used in the wild, amazon comes to mind:


CleanShot 2022-09-22 at 09 09 53

I also remember this being mentioned as a potential convenience in NavigationMenu.

they would only be for modal mode, which Popover isn't by default

Aside but I sometimes wonder if this default on Popover was the right choice from a consistency perspective.

andy-hook avatar Sep 22 '22 08:09 andy-hook

Agreed, I think this could be added to NavigationMenu and even ContextMenu as well!

Plenty of examples in iOS where context menus dim or blur the background:

darrylyeo avatar Sep 22 '22 20:09 darrylyeo

I second that. used in plenty of places, would love to see this land <3

emroot avatar Dec 20 '22 07:12 emroot

is there any progress on this?

yudinvictor avatar Jul 13 '23 15:07 yudinvictor

is there any progress on this?

artemshchirov avatar Dec 07 '23 16:12 artemshchirov

Is there a workaround for now?

jaithirani avatar Jan 16 '24 07:01 jaithirani

@jaithirani You can make a custom <Overlay/> component and nest it inside the root component. E.g. for NavigationMenu here's how I'm doing it:

const [isOpen, setIsOpen] = useState<boolean>(false);

return (
  <NavigationMenu
    defaultValue=""
    onValueChange={(val) => (val ? setIsOpen(true) : setIsOpen(false))}
    className={cn(className)}
  >
    {/* other components */}
    {isOpen && <Overlay />}
  </NavigationMenu>
);

Overlay:

export const Overlay = () => {
  return (
    <div className="absolute left-0 z-0 top-14 h-screen w-full bg-black bg-opacity-20"></div>
  );
};

ishaqibrahim-conv-cw avatar Jan 30 '24 05:01 ishaqibrahim-conv-cw