Default fieldsets to collapsed in Sanity desk view

1 replies
Last updated: Apr 14, 2020
anyone know if you can default fieldsets to be collapsed in the desk view?
AI Update

Yes, you can absolutely default fieldsets to be collapsed! You just need to use the options property in your fieldset configuration with two key settings:

{
  title: 'My Fieldset',
  name: 'myFieldset',
  options: {
    collapsible: true,  // Makes the fieldset collapsible
    collapsed: true     // Sets it to be collapsed by default
  }
}

The collapsible: true option makes the fieldset expandable/collapsible, and collapsed: true sets it to start in the collapsed state when you open a document.

You can also add a columns property if you want to arrange the fields in a grid layout when expanded:

options: {
  collapsible: true,
  collapsed: true,
  columns: 2  // Arranges fields in 2 columns
}

This is super useful for keeping your editing interface clean, especially for documents with lots of fields. You can collapse less frequently used sections (like SEO metadata or technical settings) by default, so editors see a cleaner interface when they first open a document.

One heads up: if you're using fieldsets with nested objects, the nested object might inherit the collapsible behavior from the parent fieldset. If you get unintentional double-collapse behavior, you can fix it by setting collapsible: false on the nested object itself.

More details in the fieldsets documentation and this specific answer about collapsing fieldsets.

Show original thread
1 reply
You can πŸ™‚ when you define your fieldsets, you can give them these options:
{
  title: 'My collapsed fieldset',
  name: 'collapsedFieldset',
  options: {
    collapsible: true, // Makes the whole fieldset collapsible
    collapsed: true, // Defines if the fieldset should be collapsed by default or not
    columns: 2 // Defines a grid for the fields and how many columns it should have
  }
}
More info on this page:
https://www.sanity.io/docs/object-type#fieldsets-AbjN0ykp πŸ‘

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.

Was this answer helpful?