Customizing Views
Views are the individual pages that make up the Admin Panel, such as the Dashboard, List View, and Edit View. 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 be entirely new.
There are four types of views within the Admin Panel:
To swap in your own Custom View, first determine the scope that corresponds to what you are trying to accomplish, consult the list of available components, then author your React component(s) accordingly.
Configuration
Replacing Views
To customize views, use the admin.components.views
property in your Payload Config. This is an object with keys for each view you want to customize. Each key corresponds to the view you want to customize.
The exact list of available keys depends on the scope of the view you are customizing, depending on whether it's a Root View, Collection View, or Global View. Regardless of the scope, the principles are the same.
Here is an example of how to swap out a built-in view:
For more granular control, pass a configuration object instead. Payload exposes the following properties for each view:
Property | Description |
---|---|
| Pass in the component path that should be rendered when a user navigates to this route. |
| Any valid URL path or array of paths that |
| Boolean. When true, will only match if the path matches the |
| When true, a path that has a trailing slash will only match a |
| When true, will match if the path is case sensitive. |
| Page metadata overrides to apply to this view within the Admin Panel. More details. |
* An asterisk denotes that a property is required.
Adding New Views
To add a new view to the Admin Panel, simply add your own key to the views
object. This is true for all view scopes.
New views require at least the Component
and path
properties:
Building Custom Views
Custom Views are simply Custom Components rendered at the page-level. Custom Views can either replace existing views or add entirely new ones. The process is generally the same regardless of the type of view you are customizing.
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.
Default Props
Your Custom Views will be provided with the following props:
Prop | Description |
---|---|
| An object containing |
| The Client Config object. More details. |
| The import map object. |
| An object containing the Dynamic Route Parameters. |
| An object containing the Search Parameters. |
| The document being edited. Only available in Document Views. More details. |
| The i18n object. |
| The Payload class. |
Here is an example of a Custom View component:
View Templates
Your Custom Root Views can optionally use one of the templates that Payload provides. The most common of these is the Default Template which provides the basic layout and navigation.
Here is an example of how to use the Default Template in your Custom View:
Securing Custom Views
All Custom Views are public by default. It's up to you to secure your custom views. If your view requires a user to be logged in or to have certain access rights, you should handle that within your view component yourself.
Here is how you might secure a Custom View:
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 swap out Root Views with your own, or to create entirely new ones, use the admin.components.views
property at the root of your Payload Config:
For details on how to build Custom Views, including all available props, see Building Custom Views.
The following options are available:
Property | Description |
---|---|
| The Account view is used to show the currently logged in user's Account page. |
| The main landing page of the Admin Panel. |
| Any other key can be used to add a completely new Root View. More details. |
Collection Views
Collection Views are views that are scoped under the /collections
route, such as the Collection List and Document Edit views.
To swap out Collection Views with your own, or to create entirely new ones, use the admin.components.views
property of your Collection Config:
The following options are available:
Property | Description |
---|---|
| The Edit View corresponds to a single Document for any given Collection and consists of various nested views. More details. |
| The List View is used to show a list of Documents for any given Collection. More details. |
| Any other key can be used to add a completely new Collection View. More details. |
For details on how to build Custom Views, including all available props, see Building Custom Views.
Global Views
Global Views are views that are scoped under the /globals
route, such as the Edit View.
To swap out Global Views with your own or create entirely new ones, use the admin.components.views
property in your Global Config:
The following options are available:
Property | Description |
---|---|
| The Edit View represents a single Document for any given Global and consists of various nested views. More details. |
| Any other key can be used to add a completely new Global View. More details. |
For details on how to build Custom Views, including all available props, see Building Custom Views.