Implementing Conditional-Based Options with a Custom Input Component

3 replies
Last updated: Jun 17, 2020
Hey guys, does sanity support “out of the box” conditional based options. What I mean by that is, if you check an item, it reveals other options?
Jun 17, 2020, 11:56 AM
It unfortunately does not. However, it is definitely possible to do that with a custom input component. Some relevant links:

https://www.sanity.io/guides/how-to-make-a-custom-input-component
https://www.sanity.io/docs/custom-input-widgets
There is also this collection of components that's kinda undocumented:

https://github.com/sanity-io/sanity/tree/next/packages/%40sanity/components
They're very useful for making you custom input match the rest of the studio. The
sanity.json
file there can help you figure out what paths to use in your
import
statements to get those components.
Jun 17, 2020, 2:07 PM
Jun 17, 2020, 2:56 PM
i've used it a couple of times to good effect
Jun 17, 2020, 2:56 PM

Sanity – Build the way you think, not the way your CMS thinks

Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.

Was this answer helpful?