obsidian/wiki/payloadcms/fields-collapsible.md
2026-05-15 15:25:27 +01:00

2.7 KiB

title aliases tags sources created updated
Collapsible Field
collapsible
payload-collapsible-field
payloadcms
fields
admin-ui
layout
raw/fields__collapsible.md
2026-05-15 2026-05-15

Overview

The Collapsible field is presentational-only — it has no database column and exists solely to group fields under a collapsible UI section in the Admin Panel. It does not affect the data shape stored in the document.

Config

import type { Field } from 'payload'

export const MyCollapsibleField: Field = {
  type: 'collapsible',      // required
  label: 'Advanced Options', // string | function | React component
  fields: [                 // required — nested fields
    { name: 'title', type: 'text' },
  ],
  admin: {
    initCollapsed: true,    // start collapsed (default: false)
  },
}

Config Options

Option Required Description
type Yes Must be 'collapsible'
label Yes Header text — string, ({ data, path }) => string, or React component
fields Yes Array of nested fields
admin.initCollapsed No Initial collapsed state (default false)
custom No Extension point for plugins

Dynamic Label

The label can be a function receiving { data, path } — useful for showing a document field value as the header:

label: ({ data }) => data?.title || 'Untitled',

This is the most common pattern — label shows the primary content field so the collapsed state is still informative.

Key Takeaways

  • No DB column — pure Admin Panel layout, data is stored on the parent document as if the collapsible didn't exist
  • label is required — must always provide a string, function, or React component
  • fields is required — must nest at least one field
  • initCollapsed — set to true to hide secondary/advanced fields by default, reducing visual noise
  • Dynamic label patternlabel: ({ data }) => data?.title || 'Untitled' shows content field value in the header so collapsed rows are identifiable at a glance
  • Collapsible fields can be nested inside wiki/payloadcms/fields-array or wiki/payloadcms/fields-blocks fields

Sources