Array schema types and options in Sanity.io discussed, including multi-select and custom object types.
Last updated: Sep 22, 2021
Can someone clue me into what are all of the array schema type layout options? In the docs it refers to
, but in some of the example projects I can see that
is also used. Are there other options like
or other common components? or is this something where you can pick from some of the sanity-ui components?
Sep 22, 2021, 9:20 PM
Hey User! I can see where the confusion comes from here. The tag and grid layouts work on an array of strings , whereas a list of strings can have the radio or drop down layouts. If you're looking for a multi-select, the out of the box way would be to create an array with a predefined list, like this:
! This was super helpful! Can all of the options be defined somewhere in the documentation, and or maybe organized based on use-cases, like the one you provided? Also what other
options are there besides
for lists, objects, and portable text respectively. Are there types of data that can be represented?
Sep 22, 2021, 10:34 PM
Yeah, I don't think I realized how complicated it is to find each of these different types in the documentation until putting together this answer for you! I'll start thinking of better ways to present this, whether that be changes to the docs or a guide that sort of walks folks through these different options. In regards to
, as you mentioned, there's
, and any of the custom
types you create, but you can also have an array of references to other documents in your dataset (like the example in this piece of the docs). It's also important to note that if want to be able to insert custom objects or images into your portable text editor, all you have to do is add those objects to the array that contains that
. That could be a confusing sentence, but it's much more clearly explained here .