Issue with invisible characters in Sanity schema field value resolved
I can see you've shared a field definition with a string type that has an options.list property. While you mentioned you have an issue, you didn't specify what the problem is. Let me help you understand how this field works and address common issues people encounter with this pattern.
Your field definition looks correct for creating a dropdown/radio button selector in Sanity Studio:
{
title: 'Image Position',
name: 'imagePosition',
type: 'string',
options: {
list: [
{title: 'Left', value: 'left'},
{title: 'Right', value: 'right'},
],
},
}This creates a string field that will render as a dropdown or radio buttons (depending on the layout) in the Studio, allowing editors to choose between "Left" and "Right".
Common issues with this pattern:
Not seeing the dropdown in Studio - Make sure you've restarted your Studio dev server after adding this field. Schema changes require a restart.
Getting the wrong value in queries - The stored value will be the string
'left'or'right', not the title. Make sure your frontend code checks for these values.Want radio buttons instead of dropdown - You can add
layout: 'radio'to the options:options: { list: [...], layout: 'radio' }TypeScript errors - If you're using TypeScript, wrap your field with
defineField()fromsanityas mentioned in the Fields documentation:import {defineField} from 'sanity' defineField({ title: 'Image Position', name: 'imagePosition', type: 'string', options: { list: [ {title: 'Left', value: 'left'}, {title: 'Right', value: 'right'}, ], }, })Need a default value - Add
initialValue: 'left'to set a default selection.Field not showing up in documents - Ensure this field is included in the
fieldsarray of your document schema type.
Could you share more details about what's not working as expected? For example: Is the field not appearing in Studio? Are you getting unexpected values when querying? Is there an error message?
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.