Customizing Views

Views are the individual pages that make up the Admin Panel, such as the Dashboard, List, and Edit views. One of the most powerful ways to customize the Admin Panel is to create Custom Views. These are Custom Components that can either replace built-in views or can be entirely new.

There are four types of views within the Admin Panel:

To swap in your own Custom Views, consult the list of available components. Determine the scope that corresponds to what you are trying to accomplish, then author your React component(s) accordingly.

Root Views

Root Views are the main views of the Admin Panel. These are views that are scoped directly under the /admin route, such as the Dashboard or Account views.

To easily swap Root Views with your own, or to create entirely new ones, use the admin.components.views property of your root Payload Config:

1
import { buildConfig } from 'payload'
2
3
const config = buildConfig({
4
// ...
5
admin: {
6
components: {
7
views: {
8
Dashboard: MyCustomDashboardView,
9
},
10
},
11
},
12
})

For details on how to build Custom Views, see Building Custom Views.

The following options are available:

PropertyDescription
AccountThe Account view is used to show the currently logged in user's Account page.
DashboardThe main landing page of the Admin Panel.

For more granular control, pass a configuration object instead. Payload exposes the following properties for each view:

PropertyDescription
Component *Pass in the component that should be rendered when a user navigates to this route.
path *Any valid URL path or array of paths that path-to-regexp understands.
exactBoolean. When true, will only match if the path matches the usePathname() exactly.
strictWhen true, a path that has a trailing slash will only match a location.pathname with a trailing slash. This has no effect when there are additional URL segments in the pathname.
sensitiveWhen true, will match if the path is case sensitive.

* An asterisk denotes that a property is required.

Adding New Views

To add a new views to the Admin Panel, simply add your own key to the views object with at least a path and Component property. For example:

1
import { buildConfig } from 'payload'
2
3
const config = buildConfig({
4
// ...
5
admin: {
6
components: {
7
views: {
8
MyCustomView: {
9
Component: MyCustomView,
10
path: '/my-custom-view',
11
},
12
},
13
},
14
},
15
})

The above example shows how to add a new Root View, but the pattern is the same for Collection Views, Global Views, and Document Views. For help on how to build your own Custom Views, see Building Custom Views.

Collection Views

Collection Views are views that are scoped under the /collections route, such as the Collection List and Document Edit views.

To easily swap out Collection Views with your own, or to create entirely new ones, use the admin.components.views property of your Collection Config:

1
import type { SanitizedCollectionConfig } from 'payload'
2
3
export const MyCollectionConfig: SanitizedCollectionConfig = {
4
// ...
5
admin: {
6
components: {
7
views: {
8
Edit: MyCustomEditView,
9
},
10
},
11
},
12
}

For details on how to build Custom Views, see Building Custom Views.

The following options are available:

PropertyDescription
EditThe Edit View is used to edit a single document for any given Collection. More details.
ListThe List View is used to show a list of documents for any given Collection.

Global Views

Global Views are views that are scoped under the /globals route, such as the Document Edit View.

To easily swap out Global Views with your own or create entirely new ones, use the admin.components.views property in your Global Config:

1
import type { SanitizedGlobalConfig } from 'payload'
2
3
export const MyGlobalConfig: SanitizedGlobalConfig = {
4
// ...
5
admin: {
6
components: {
7
views: {
8
Edit: MyCustomEditView,
9
},
10
},
11
},
12
})

For details on how to build Custom Views, see Building Custom Views.

The following options are available:

PropertyDescription
EditThe Edit View is used to edit a single document for any given Global. More details.

Document Views

Document Views are views that are scoped under the /collections/:collectionSlug/:id or the /globals/:globalSlug route, such as the Edit View or the API View. All Document Views keep their overall structure across navigation changes, such as their title and tabs, and replace only the content below.

To easily swap out Document Views with your own, or to create entirely new ones, use the admin.components.views.Edit[key] property in your Collection Config or Global Config:

1
import type { SanitizedCollectionConfig } from 'payload'
2
3
export const MyCollectionOrGlobalConfig: SanitizedCollectionConfig = {
4
// ...
5
admin: {
6
components: {
7
views: {
8
Edit: {
9
API: {
10
Component: MyCustomAPIView,
11
},
12
},
13
},
14
},
15
},
16
})

For details on how to build Custom Views, see Building Custom Views.

The following options are available:

PropertyDescription
DefaultThe Default view is the primary view in which your document is edited.
VersionsThe Versions view is used to view the version history of a single document. More details.
VersionThe Version view is used to view a single version of a single document for a given collection. More details.
APIThe API view is used to display the REST API JSON response for a given document.
LivePreviewThe LivePreview view is used to display the Live Preview interface. More details.

Document Tabs

Each Document View can be given a new tab in the Edit View, if desired. Tabs are highly configurable, from as simple as changing the label to swapping out the entire component, they can be modified in any way. To add or customize tabs in the Edit View, use the Component.Tab key:

1
import type { SanitizedCollectionConfig } from 'payload'
2
3
export const MyCollection: SanitizedCollectionConfig = {
4
slug: 'my-collection',
5
admin: {
6
components: {
7
views: {
8
Edit: {
9
MyCustomTab: {
10
Component: MyCustomTab,
11
path: '/my-custom-tab',
12
Tab: MyCustomTab
13
},
14
AnotherCustomView: {
15
Component: AnotherCustomView,
16
path: '/another-custom-view',
17
Tab: {
18
label: 'Another Custom View',
19
href: '/another-custom-view',
20
}
21
},
22
},
23
},
24
},
25
},
26
}

Building Custom Views

Custom Views are just Custom Components rendered at the page-level. To understand how to build Custom Views, first review the Building Custom Components guide. Once you have a Custom Component ready, you can use it as a Custom View.

1
import type { SanitizedCollectionConfig } from 'payload'
2
import { MyCustomView } from './MyCustomView'
3
4
export const MyCollectionConfig: SanitizedCollectionConfig = {
5
// ...
6
admin: {
7
components: {
8
views: {
9
Edit: MyCustomView,
10
},
11
},
12
},
13
}

Your Custom Views will be provided with the following props:

PropDescription
userThe currently logged in user.
localeThe current Locale of the Admin Panel.
navGroupsThe grouped navigation items according to admin.group in your Collection Config or Global Config.
paramsAn object containing the Dynamic Route Parameters.
permissionsThe permissions of the currently logged in user.
searchParamsAn object containing the Search Parameters.
visibleEntitiesThe current user's visible entities according to your Access Control.
Next

Customizing Fields