# Group Field

Source: https://payloadcms.com/docs/beta/fields/group

The Group Field allows [Fields](/docs/v4/fields/overview.md) to be nested under a common property name. It also groups fields together visually in the [Admin Panel](/docs/v4/admin/overview.md).

![Shows a Group field in the Payload Admin Panel](https://payloadcms.com/images/docs/fields/group.png)

_Admin Panel screenshot of a Group field_

To add a Group Field, set the `type` to `group` in your [Field Config](/docs/v4/fields/overview.md):

```ts
import type { Field } from 'payload'

export const MyGroupField: Field = {
  // ...
  // highlight-start
  type: 'group',
  fields: [
    // ...
  ],
  // highlight-end
}
```

## Config Options

| Option              | Description                                                                                                                                                                                                                                                                        |
| ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **`name`**          | To be used as the property name when stored and retrieved from the database. [More details](/docs/v4/fields/overview.md#field-names).                                                                                                                                                    |
| **`fields`** \*     | Array of field types to nest within this Group.                                                                                                                                                                                                                                    |
| **`label`**         | Used as a heading in the Admin Panel and to name the generated GraphQL type. Defaults to the field name, if defined.                                                                                                                                                               |
| **`validate`**      | Provide a custom validation function that will be executed on both the Admin Panel and the backend. [More details](/docs/v4/fields/overview.md#validation).                                                                                                                              |
| **`saveToJWT`**     | If this field is top-level and nested in a config supporting [Authentication](/docs/v4/authentication/overview.md), include its data in the user JWT.                                                                                                                                    |
| **`hooks`**         | Provide Field Hooks to control logic for this field. [More details](/docs/v4/hooks/fields.md).                                                                                                                                                                                              |
| **`access`**        | Provide Field Access Control to denote what users can see and do with this field's data. [More details](/docs/v4/access-control/fields.md).                                                                                                                                                 |
| **`hidden`**        | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin Panel.                                                                                                                                   |
| **`defaultValue`**  | Provide an object of data to be used for this field's default value. [More details](/docs/v4/fields/overview.md#default-values).                                                                                                                                                         |
| **`localized`**     | Enable localization for this field. Requires [localization to be enabled](/docs/v4/configuration/localization.md) in the Base config. If enabled, a separate, localized set of all data within this Group will be kept, so there is no need to specify each nested field as `localized`. |
| **`admin`**         | Admin-specific configuration. [More details](#admin-options).                                                                                                                                                                                                                      |
| **`custom`**        | Extension point for adding custom data (e.g. for plugins)                                                                                                                                                                                                                          |
| **`interfaceName`** | Create a top level, reusable [Typescript interface](/docs/v4/typescript/generating-types.md#custom-field-interfaces) & [GraphQL type](/docs/v4/graphql/graphql-schema.md#custom-field-schemas).                                                                                                |
| **`jsonSchema`**    | Override field JSON Schema used for type generation and MCP validation                                                                                                                                                                                                             |
| **`virtual`**       | Provide `true` to disable field in the database. See [Virtual Fields](https://payloadcms.com/blog/learn-how-virtual-fields-can-help-solve-common-cms-challenges)                                                                                                                   |

_\* An asterisk denotes that a property is required._

## Admin Options

To customize the appearance and behavior of the Group Field in the [Admin Panel](/docs/v4/admin/overview.md), you can use the `admin` option:

```ts
import type { Field } from 'payload'

export const MyGroupField: Field = {
  // ...
  admin: {
    // highlight-line
    // ...
  },
}
```

The Group Field inherits all of the default admin options from the base [Field Admin Config](/docs/v4/fields/overview.md#admin-options), plus the following additional options:

| Option           | Description                                                                                                                                                                                                                                      |
| ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **`hideGutter`** | Set this property to `true` to hide this field's gutter within the Admin Panel. The field gutter is rendered as a vertical line and padding, but often if this field is nested within a Group, Block, or Array, you may want to hide the gutter. |

## Example

```ts
import type { CollectionConfig } from 'payload'

export const ExampleCollection: CollectionConfig = {
  slug: 'example-collection',
  fields: [
    {
      name: 'pageMeta',
      type: 'group', // required
      interfaceName: 'Meta', // optional
      fields: [
        // required
        {
          name: 'title',
          type: 'text',
          required: true,
          minLength: 20,
          maxLength: 100,
        },
        {
          name: 'description',
          type: 'textarea',
          required: true,
          minLength: 40,
          maxLength: 160,
        },
      ],
    },
  ],
}
```

## Presentational group fields

You can also use the Group field to only visually group fields without affecting the data structure. Not defining a `name` will render just the grouped fields (no nested object is created). If you want the group to appear as a titled section in the Admin UI, set a `label`.

```ts
import type { CollectionConfig } from 'payload'

export const ExampleCollection: CollectionConfig = {
  slug: 'example-collection',
  fields: [
    {
      label: 'Page meta', // label only → presentational
      type: 'group', // required
      fields: [
        {
          name: 'title',
          type: 'text',
          required: true,
          minLength: 20,
          maxLength: 100,
        },
        {
          name: 'description',
          type: 'textarea',
          required: true,
          minLength: 40,
          maxLength: 160,
        },
      ],
    },
  ],
}
```

## Named group

```ts
import type { CollectionConfig } from 'payload'

export const ExampleCollection: CollectionConfig = {
  slug: 'example-collection',
  fields: [
    {
      name: 'pageMeta', // name → nested object in data
      label: 'Page meta',
      type: 'group', // required
      fields: [
        {
          name: 'title',
          type: 'text',
          required: true,
          minLength: 20,
          maxLength: 100,
        },
        {
          name: 'description',
          type: 'textarea',
          required: true,
          minLength: 40,
          maxLength: 160,
        },
      ],
    },
  ],
}
```
