✨Discover storytelling in the AI age with Pixar's Matthew Luhn at Sanity Connect, May 8th—register now

Changing button behavior to open a modal and then an edit screen using Sanity UI's Dialog component.

2 replies
Last updated: Feb 29, 2024
Hi all, is there anyway to change behaviour of this button? I want it to open an modal and then based on selection open an edit screen. Thank you
Feb 29, 2024, 12:01 PM
You would need to create a custom component to handle that.
Feb 29, 2024, 3:46 PM
If you do, you can pull in Sanity UI's Dialog component and show it or hide it (open or close, basically) with a simple state-setter.
The interesting and fun thing is that even though it's presentationally "over" the document (and field), it will have full access to the information. I just used it to send people out to a really long virtualized list component that didn't make sense to use/see inline (since it's heavily dependent on scroll and you wouldn't wanna whoosh down the document every time you needed to use it) and their choices get saved while still in the modal.
Feb 29, 2024, 11:42 PM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?