use of multiple triggers is possible? #2709
-
i'm developing a personal project, and i wanted to use 2 triggers, one to open an "add courses" modal and another to open a "delete courses" modal, i waned to know if i can use 2 triggers with identifiers to open their respective modal, or is there another better approach? import logoImage from '../assets/logo.svg'; import { useNavigate } from "react-router-dom"; //programação imperativa vs declarativa (react) <Dialog.Root> <Dialog.Trigger id="add-discipline-trigger" type="button" className="border border-red-500 font-semibold rounded-lg px-6 py-4 flex items-center gap-3 hover:border-red-300 transition-colors focus:outline-none focus:ring-2 focus:ring-red-600 focus:ring-offset-2 focus:ring-offset-background" > {/* */} Adicionar disciplina </Dialog.Trigger>
}` |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
To achieve multiple triggers that open the same dialog, instead of adding multiple triggers to a single dialog instance, instead you need to think of reusing components. Here's an old demo: https://codesandbox.io/p/sandbox/reused-dialogcontent-0oikl?file=%2Fsrc%2Findex.tsx |
Beta Was this translation helpful? Give feedback.
To achieve multiple triggers that open the same dialog, instead of adding multiple triggers to a single dialog instance, instead you need to think of reusing components.
Here's an old demo: https://codesandbox.io/p/sandbox/reused-dialogcontent-0oikl?file=%2Fsrc%2Findex.tsx