
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeYou can access sibling field values in a custom input component using the useFormValue hook from Sanity Studio. This lets you read values from other fields in the same document and use them to customize how your component renders.
Here's how to implement your specific example of rendering text with a font size from a sibling field:
import { useFormValue } from 'sanity'
const CustomTextInput = (props) => {
// Access the sibling fontSize field
const fontSize = useFormValue(['fontSize'])
return (
<div>
<input
{...props.inputProps}
style={{ fontSize: fontSize || '16px' }}
value={props.value || ''}
onChange={(e) => props.onChange(e.target.value)}
/>
</div>
)
}
export default CustomTextInputThe useFormValue hook accepts a path array that specifies which field to access:
useFormValue(['fieldName'])useFormValue(['parent', 'child', 'fieldName'])useFormValue([])The hook automatically re-renders your component when the referenced field changes, so your text input will dynamically update its styling as the user modifies the fontSize field.
Multiple sibling fields:
const fontSize = useFormValue(['fontSize'])
const fontWeight = useFormValue(['fontWeight'])
const color = useFormValue(['color'])
// Apply all styles
<input style={{ fontSize, fontWeight, color }} />Conditional rendering based on sibling:
const showAdvanced = useFormValue(['showAdvancedOptions'])
return showAdvanced ? <AdvancedInput {...props} /> : <SimpleInput {...props} />Working with array items: When your input is inside an array, you can access other fields in the same array item using the path:
const { path } = props
const parentPath = path.slice(0, -1)
const siblingValue = useFormValue([...parentPath, 'siblingFieldName'])useFormValue only works inside custom input components within the form builder context—you can't use it in document actions or other Studio contextsprops.document or props.parentundefined if the field doesn't exist or hasn't been set yet, so provide fallback valuesThis approach gives you full control over creating dynamic, interdependent form experiences without needing to make API calls or manage complex state yourself.
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.
Content operations
Content backend


The only platform powering content operations
By Industry


Tecovas strengthens their customer connections
Build and Share

Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag store