Programmatic control
You can open the feedback modal from your own JavaScript instead of relying on the built-in <feedback-button> trigger. This is useful when you want a custom trigger, such as a link, an icon, or a keyboard shortcut.
The openModal() method
<feedback-modal> exposes a public openModal() method:
openModal(): Promise<void>
Calling it opens the feedback modal, playing the same entrance animation as when a user clicks a <feedback-button>.
openModal() is only available on <feedback-modal>. <feedback-button> doesn't expose this method: it calls openModal() on its own internal <feedback-modal> element when clicked.
Usage
To call openModal(), get a reference to the <feedback-modal> element and call the method on it:
-
Add a
<feedback-modal>element to your page with anidyou can select later:<feedback-modal id="my-feedback-modal" project="YOUR_PROJECT_ID"></feedback-modal> -
Add your own trigger element, such as a link or icon:
<a href="#" id="custom-feedback-trigger">Give feedback</a> -
Get a reference to the
<feedback-modal>element and callopenModal()when your trigger is activated:document.addEventListener('DOMContentLoaded', () => {const feedbackModal = document.getElementById('my-feedback-modal');const trigger = document.getElementById('custom-feedback-trigger');trigger.addEventListener('click', (event) => {event.preventDefault();feedbackModal.openModal();});});
See Embedded mode if you want the feedback form to display without any trigger at all.