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 View, first 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 swap Root Views with your own, or to create entirely new ones, use the admin.components.views
property of your root Payload Config:
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 what that might look like:
For details on how to build Custom Views, including all available props, see Building Custom Views.
The following options are available:
Property | Description |
---|---|
account | The Account view is used to show the currently logged in user's Account page. |
dashboard | The main landing page of the Admin Panel. |
For more granular control, pass a configuration object instead. Payload exposes the following properties for each view:
Property | Description |
---|---|
Component * | Pass in the component path 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. |
exact | Boolean. When true, will only match if the path matches the usePathname() exactly. |
strict | When 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. |
sensitive | When true, will match if the path is case sensitive. |
meta | 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 views to the Admin Panel, simply add your own key to the views
object with at least a path
and Component
property. For example:
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 swap out Collection Views with your own, or to create entirely new ones, use the admin.components.views
property of your Collection Config:
For details on how to build Custom Views, including all available props, see Building Custom Views.
The following options are available:
Property | Description |
---|---|
edit | The Edit View is used to edit a single document for any given Collection. More details. |
list | The 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 swap out Global Views with your own or create entirely new ones, use the admin.components.views
property in your Global Config:
For details on how to build Custom Views, including all available props, see Building Custom Views.
The following options are available:
Property | Description |
---|---|
edit | The 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 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:
For details on how to build Custom Views, including all available props, see Building Custom Views.
The following options are available:
Property | Description |
---|---|
root | The Root View overrides all other nested views and routes. No document controls or tabs are rendered when this key is set. |
default | The Default View is the primary view in which your document is edited. It is rendered within the "Edit" tab. |
versions | The Versions View is used to navigate the version history of a single document. It is rendered within the "Versions" tab. More details. |
version | The Version View is used to edit a single version of a document. It is rendered within the "Version" tab. More details. |
api | The API View is used to display the REST API JSON response for a given document. It is rendered within the "API" tab. |
livePreview | The LivePreview view is used to display the Live Preview interface. It is rendered within the "Live Preview" tab. 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 tab
key:
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.
Default Props
Your Custom Views will be provided with the following props:
Prop | Description |
---|---|
initPageResult | An object containing req , payload , permissions , etc. |
clientConfig | The Client Config object. More details. |
importMap | The import map object. |
params | An object containing the Dynamic Route Parameters. |
searchParams | An object containing the Search Parameters. |
doc | The document being edited. Only available in Document Views. More details. |