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

retrieve the values of sibling fields to use in rendering an inputComponent

3 replies
Last updated: Feb 7, 2021
How can I retrieve the values of sibling fields to use in rendering an inputComponent? For example I want to render the text value but with the font specified in the fontSize sibling field.
Feb 7, 2021, 8:53 PM
One thing I tried to do was to do a client.fetch query but the problem here is that I could find any kind of id being passed in a a prop in my “TextInput” component, so it wouldn’t be possible to corroborate this data to the data queried from the api.
Feb 7, 2021, 8:57 PM
This is a view of the input component as of now. I cropped the picture below where I put in my projectid and api key for obvious reasons.
Feb 7, 2021, 8:58 PM
Hi Matthew, could you try wrapping your component in
? As follows:
import { withDocument } from 'part:@sanity/form-builder'


const TextInput = (props) => {

export default withDocument(TextInput)
This should give you access to a
prop that contains your document's content.
Feb 7, 2021, 9:59 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?