🔮 Sanity Create is here. Writing is reinvented. Try now, no developer setup

Creating a custom input field in Sanity for auto-generating a field based on another's value.

5 replies
Last updated: Aug 18, 2021
Hi there, got another Sanity question. I am trying to have a field within a schema that is being auto-generated --perhaps when a button next to it is being pressed-- based on another's field value. Quite similar to how slug is being generated with the out-of-the-box slugify functionality, when the 'Generate' button is pressed. I am a bit lost and don't know where to even start looking. Can anyone point me towards the right direction? Thank you.
Aug 18, 2021, 9:12 AM
Hi there! Sounds like you want to create a custom input, so I would start with this documentation: https://www.sanity.io/docs/custom-input-widgets
It includes information about how to access other fields in the same documents at the bottom of the article, and to make it look native to the Studio, you can build it with
https://www.sanity.io/ui ! Hope that helps, let me know if you need more help! 👍
Aug 18, 2021, 9:40 AM
That's all I needed I think, many thanks 🙏
Aug 18, 2021, 9:42 AM
Great! Also, here’s an example of how to use Sanity UI to get the styles looking like the slug input 👍 https://www.sanity.io/ui/arcade?mode=jsx&jsx=eJxVT9sKwjAMfZ5fEfoDRX1NB24gCD76A8V2W8[…]kSsNgYdXlyiKSgj84b1XZxZKV%2FNtmzQJ0Lod4aCxKQXyo%2FpydCAg%3D%3D
Aug 18, 2021, 9:45 AM
Great! Also, here’s an example of how to use Sanity UI to get the styles looking like the slug input 👍 https://www.sanity.io/ui/arcade?mode=jsx&jsx=eJxVT9sKwjAMfZ5fEfoDRX1NB24gCD76A8V2W8[…]kSsNgYdXlyiKSgj84b1XZxZKV%2FNtmzQJ0Lod4aCxKQXyo%2FpydCAg%3D%3D
Aug 18, 2021, 9:45 AM
Hi there! Sounds like you want to create a custom input, so I would start with this documentation: https://www.sanity.io/docs/custom-input-widgets
It includes information about how to access other fields in the same documents at the bottom of the article, and to make it look native to the Studio, you can build it with
https://www.sanity.io/ui ! Hope that helps, let me know if you need more help! 👍
Aug 18, 2021, 9:40 AM

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?