Skip to content

[Menu] Bring your own Popover #3571

Answered by diegohaz
bengry asked this question in Questions
Discussion options

You must be logged in to vote

If you don't want to manage the state with React, you can rely on Ariakit stores:

// You can optionally pass `open` and `setOpen` from external props to the menu store
const menu = Ariakit.useMenuStore({ open: props.open, setOpen: props.onClose });
const internalOpen = menu.useState("open");

<Ariakit.MenuProvider store={menu}>
  <RadixPopover.Root open={internalOpen} onOpenChange={menu.setOpen}>

For the content element, you can either use the MenuList component, or use Menu with updatePosition={() => {}} and delegate the auto focus control to Ariakit by disabling it on the Radix side:

<RadixPopover.Content
  onOpenAutoFocus={(event) => event.preventDefault()}
>

There's a few Radix UI exa…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by bengry
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants