Get a peek at our latest innovations at Sanity Product Day on Dec 8th →

How to Show a List As Radio Button?

2 replies
Last updated: Jun 24, 2020

I’m unable to show a list as

radio
buttons besides following the documentation
{
      title: "Num Cols",
      name: "cols",
      type: "array",
      of: [{ type: "string" }],
      options: {
        list: [
          { title: "One Column", value: "1" },
          { title: "Two Columns", value: "2" },
          { title: "Three Col", value: "3" }
        ],
        layout: "radio",
        direction: "horizontal"
      }
    }
Any idea what I’m doing wrong?

it still shows as checkboxes

Jun 24, 2020, 4:11 PM

try this

{
      title: "Num Cols",
      name: "cols",
      type: "string",
      options: {
        list: [
          { title: "One Column", value: "1" },
          { title: "Two Columns", value: "2" },
          { title: "Three Col", value: "3" }
        ],
        layout: "radio",
        direction: "horizontal"
      }
    }

Jun 24, 2020, 4:15 PM

❤️

Jun 24, 2020, 4:17 PM

Sanity.io: Get the most out of your content

Sanity.io is a platform to build websites and applications. It comes with great APIs that let you treat content like data. Free to get started, and pay-as-you-go on all plans. Find out more.