Skip to content

Dialog with multiple Trigger's #1532

Answered by benoitgrelard
avremel asked this question in Help
Discussion options

You must be logged in to vote

Although it might look like multiple triggers would be supported, it is not.
If you think about it, it doesn't make much sense, as accessibility also belongs to the trigger, so unfortunately the solution proposed by @gabrielmlinassi isn't great for that reason.

The solution we would recommend isn't far though. The key is that instead of thinking of reusing a single "instance", think about reusing components instead.

Here's an old demo showing the same principle with a reused "content": https://codesandbox.io/s/reused-dialogcontent-0oikl

You could abstract the whole Dialog if you wanted to as well:

function DeleteProductDialog(props) {
  return (
    <Dialog.Root {...props}>
      {children}

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
5 replies
@avremel
Comment options

@benoitgrelard
Comment options

@gabrielmlinassi
Comment options

@benoitgrelard
Comment options

@johnajunghans
Comment options

Answer selected by avremel
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
4 participants