Radio buttons showing as checkboxes in Sanity array field with list options
The issue you're experiencing is that you're using type: "array" when you should be using type: "string" for radio buttons with a predefined list.
According to the Sanity string type documentation, when you want radio buttons for a predefined list of options, you need to use the string type, not the array type. Here's the corrected schema:
{
title: "Num Cols",
name: "cols",
type: "string", // Change from "array" to "string"
options: {
list: [
{ title: "One Column", value: "1" },
{ title: "Two Columns", value: "2" },
{ title: "Three Col", value: "3" }
],
layout: "radio",
direction: "horizontal"
}
}Key differences:
- Type: Use
type: "string"instead oftype: "array" - Remove
ofproperty: Theofproperty is only for array types - Single selection: This will allow selecting only one value (single choice)
The layout: "radio" option only works with string types that have a predefined list. When you use type: "array", Sanity treats it as a multi-select field and renders it as checkboxes, which is why you were seeing that behavior.
If you actually need multiple selections (an array of strings), then checkboxes are the correct UI. Arrays with predefined lists support layout: "tags" or layout: "grid" options, but not layout: "radio" since radio buttons are inherently single-selection controls.
Show original thread2 replies
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.