Adding headings and text to fieldsets in Sanity projects.
8 replies
Last updated: May 25, 2021
R
Hey there! Just started my first Sanity project and loving it so far. I have a bunch of fieldsets that I would like to add a heading, and some content to just to give some more context on what the following fields will relate to but I can't seem to find a way to add those. Can anyone point me in the right direction? Cheers!
May 24, 2021, 10:48 PM
Hey Ryan! Welcome! You can specify a title and description on your fieldsets like this:
You can find the documentation on this
here .
{ type: 'object', name: 'person', fieldsets: [ {name: 'social', title: 'Social media handles', description: 'A collection of social media handles'} ], fields: [ { title: 'Name', name: 'name', type: 'string' }, { title: 'Twitter', name: 'twitter', type: 'string', fieldset: 'social' }, { title: 'Instagram', name: 'instagram', type: 'string', fieldset: 'social' }, { title: 'Facebook', name: 'facebook', type: 'string', fieldset: 'social' } ] }
here .
May 24, 2021, 10:59 PM
R
Oh excellent, thank you. I didn't see in the documentation that you could add a description but I also should have tried it 😄
Is it possible to add stand-alone headings and text do you know?
Is it possible to add stand-alone headings and text do you know?
May 24, 2021, 11:04 PM
The description bit is missing from the docs, but I gave it a go and it worked out!Hmmm. I’m not sure re:separate headings. How are you picturing them? Like moving the headings in between the fieldset’s fields? Or am I misunderstanding?
May 24, 2021, 11:09 PM
R
Yeah I was thinking of something like the following:
[ {name: "field", "type: "string", title: "Example field"}, {type: "heading", level: 4, title: "This is a heading"}, {type: "message", title: "This is a stand-alone piece of text"}, {name: "field2", "type: "string", title: "Example field"}, ]
May 24, 2021, 11:10 PM
R
Just to follow up on this, I just ended up making my own custom components 🙂
May 25, 2021, 2:55 AM
R
Just to follow up on this, I just ended up making my own custom components 🙂
May 25, 2021, 2:55 AM
If you’d like, you can publish them to the community studio here !
May 25, 2021, 3:05 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.