Unlock seamless workflows and faster delivery with our latest releases - Join the deep dive

Schema - How to make a Field that lets a User Select from Defined Options

1 replies
Last updated: Oct 25, 2021
while creating schema, how can i make a field that lets user select from one of the options for example , they can select from ['car', 'bicycle', 'truck'] ?
Oct 25, 2021, 9:04 PM
You can create a list of predefined strings using
options.list
. For example:
{
  title: 'Vehicle',
  name: 'vehicle',
  type: 'string',
  options: {
    list: [
      {title: 'Car', value: 'car'},
      {title: 'Bicycle', value: 'bicycle'}
    ], // <-- predefined values
  }
}
Oct 25, 2021, 9:08 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?