Skip to content

Commit 3229b9a

Browse files
authored
docs: dedicated custom components docs (#10987)
Adds a dedicated "Custom Components" section to the docs. As users become familiar with building custom components, not all areas that support customization are well documented. Not only this, but the current pattern does not allow for deep elaboration on these concepts without their pages growing to an unmanageable size. Custom components in general is a large enough topic to merit a standalone section with subpages. This change will make navigation much more intuitive, help keep page size down, and provide room to document every single available custom component with snippets to show exactly how they are typed, etc. This is a substantial change to the docs, here is the overview: - The "Admin > Customizing Components" doc is now located at "Custom Components > overview" - The "Admin > Views" doc is now located at "Custom Components > Custom Views" - There is a new "Custom Components > Edit View" doc - There is a new "Custom Components > List View" doc - The information about root components within the "Admin > Customizing Components" doc has been moved to a new "Custom Components > Root Components" doc - The information about custom providers within the "Admin > Customizing Components" doc has been moved to a new "Custom Components > Custom Providers" doc Similar to the goals of #10743, #10742, and #10741. Fixes #10872 and initial scaffolding for #10353. Dependent on #11126. This change will require the following redirects to be set up: - `/docs/admin/hooks` → `/docs/admin/react-hooks` - `/docs/admin/components` → `/docs/custom-components/overview` - `/docs/admin/views` → `/docs/custom-components/views`
1 parent b80010b commit 3229b9a

File tree

29 files changed

+2202
-656
lines changed

29 files changed

+2202
-656
lines changed

docs/admin/customizing-css.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Customizing CSS & SCSS
33
label: Customizing CSS
4-
order: 80
4+
order: 50
55
desc: Customize the Payload Admin Panel further by adding your own CSS or SCSS style sheet to the configuration, powerful theme and design options are waiting for you.
66
keywords: admin, css, scss, documentation, Content Management System, cms, headless, javascript, node, react, nextjs
77
---
@@ -30,7 +30,7 @@ Here is an example of how you might target the Dashboard View and change the bac
3030

3131
<Banner type="warning">
3232
**Note:**
33-
If you are building [Custom Components](./components), it is best to import your own stylesheets directly into your components, rather than using the global stylesheet. You can continue to use the [CSS library](#css-library) as needed.
33+
If you are building [Custom Components](../custom-components/overview), it is best to import your own stylesheets directly into your components, rather than using the global stylesheet. You can continue to use the [CSS library](#css-library) as needed.
3434
</Banner>
3535

3636
### Specificity rules

docs/admin/locked-documents.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Document Locking
33
label: Document Locking
4-
order: 90
4+
order: 40
55
desc: Ensure your documents are locked during editing to prevent concurrent changes from multiple users and maintain data integrity.
66
keywords: locking, document locking, edit locking, document, concurrency, Payload, headless, Content Management System, cms, javascript, react, node, nextjs
77
---

docs/admin/metadata.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ The Global Meta config has the same options as the [Root Metadata](#root-metadat
194194

195195
## View Metadata
196196

197-
View Metadata is the metadata that is applied to specific [Views](./views) within the Admin Panel. This metadata is used to customize the title and description of a specific view, overriding any metadata set at the [Root](#root-metadata), [Collection](#collection-metadata), or [Global](#global-metadata) level.
197+
View Metadata is the metadata that is applied to specific [Views](../custom-components/custom-views) within the Admin Panel. This metadata is used to customize the title and description of a specific view, overriding any metadata set at the [Root](#root-metadata), [Collection](#collection-metadata), or [Global](#global-metadata) level.
198198

199199
To customize View Metadata, use the `meta` key within your View Config:
200200

docs/admin/overview.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ keywords: admin, components, custom, customize, documentation, Content Managemen
88

99
Payload dynamically generates a beautiful, [fully type-safe](../typescript/overview) Admin Panel to manage your users and data. It is highly performant, even with 100+ fields, and is translated in over 30 languages. Within the Admin Panel you can manage content, [render your site](../live-preview/overview), [preview drafts](./preview), [diff versions](../versions/overview), and so much more.
1010

11-
The Admin Panel is designed to [white-label your brand](https://payloadcms.com/blog/white-label-admin-ui). You can endlessly customize and extend the Admin UI by swapping in your own [Custom Components](./components)—everything from simple field labels to entire views can be modified or replaced to perfectly tailor the interface for your editors.
11+
The Admin Panel is designed to [white-label your brand](https://payloadcms.com/blog/white-label-admin-ui). You can endlessly customize and extend the Admin UI by swapping in your own [Custom Components](../custom-components/overview)—everything from simple field labels to entire views can be modified or replaced to perfectly tailor the interface for your editors.
1212

1313
The Admin Panel is written in [TypeScript](https://www.typescriptlang.org) and built with [React](https://react.dev) using the [Next.js App Router](https://nextjs.org/docs/app). It supports [React Server Components](https://react.dev/reference/rsc/server-components), enabling the use of the [Local API](/docs/local-api/overview) on the front-end. You can install Payload into any [existing Next.js app in just one line](../getting-started/installation) and [deploy it anywhere](../production/deployment).
1414

1515
<Banner type="success">
16-
The Payload Admin Panel is designed to be as minimal and straightforward as possible to allow easy customization and control. [Learn more](./components).
16+
The Payload Admin Panel is designed to be as minimal and straightforward as possible to allow easy customization and control. [Learn more](../custom-components/overview).
1717
</Banner>
1818

1919
<LightDarkImage
@@ -91,7 +91,7 @@ The following options are available:
9191
| **`avatar`** | Set account profile picture. Options: `gravatar`, `default` or a custom React component. |
9292
| **`autoLogin`** | Used to automate log-in for dev and demonstration convenience. [More details](../authentication/overview). |
9393
| **`buildPath`** | Specify an absolute path for where to store the built Admin bundle used in production. Defaults to `path.resolve(process.cwd(), 'build')`. |
94-
| **`components`** | Component overrides that affect the entirety of the Admin Panel. [More details](./components). |
94+
| **`components`** | Component overrides that affect the entirety of the Admin Panel. [More details](../custom-components/overview). |
9595
| **`custom`** | Any custom properties you wish to pass to the Admin Panel. |
9696
| **`dateFormat`** | The date format that will be used for all dates within the Admin Panel. Any valid [date-fns](https://date-fns.org/) format pattern can be used. |
9797
| **`livePreview`** | Enable real-time editing for instant visual feedback of your front-end application. [More details](../live-preview/overview). |
@@ -178,7 +178,7 @@ The following options are available:
178178

179179
<Banner type="success">
180180
**Tip:**
181-
You can easily add _new_ routes to the Admin Panel through [Custom Endpoints](../rest-api/overview#custom-endpoints) and [Custom Views](./views).
181+
You can easily add _new_ routes to the Admin Panel through [Custom Endpoints](../rest-api/overview#custom-endpoints) and [Custom Views](../custom-components/custom-views).
182182
</Banner>
183183

184184
#### Customizing Root-level Routes
@@ -233,7 +233,7 @@ The following options are available:
233233

234234
<Banner type="success">
235235
**Note:**
236-
You can also swap out entire _views_ out for your own, using the `admin.views` property of the Payload Config. See [Custom Views](./views) for more information.
236+
You can also swap out entire _views_ out for your own, using the `admin.views` property of the Payload Config. See [Custom Views](../custom-components/custom-views) for more information.
237237
</Banner>
238238

239239
## I18n

docs/admin/preferences.mdx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Managing User Preferences
33
label: Preferences
4-
order: 70
4+
order: 60
55
desc: Store the preferences of your users as they interact with the Admin Panel.
66
keywords: admin, preferences, custom, customize, documentation, Content Management System, cms, headless, javascript, node, react, nextjs
77
---
@@ -81,7 +81,7 @@ import { usePreferences } from '@payloadcms/ui'
8181

8282
const lastUsedColorsPreferenceKey = 'last-used-colors';
8383

84-
const CustomComponent = (props) => {
84+
export function CustomComponent() {
8585
const { getPreference, setPreference } = usePreferences();
8686

8787
// Store the last used colors in local state
@@ -154,8 +154,6 @@ const CustomComponent = (props) => {
154154
</Fragment>
155155
)}
156156
</div>
157-
);
158-
};
159-
160-
export default CustomComponent;
157+
)
158+
}
161159
```

docs/admin/preview.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Preview
33
label: Preview
4-
order: 50
4+
order: 30
55
desc: Enable links to your front-end to preview published or draft content.
66
keywords: admin, components, preview, documentation, Content Management System, cms, headless, javascript, node, react, nextjs
77
---

docs/admin/hooks.mdx renamed to docs/admin/react-hooks.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
---
22
title: React Hooks
33
label: React Hooks
4-
order: 40
4+
order: 50
55
desc: Make use of all of the powerful React hooks that Payload provides.
66
keywords: admin, components, custom, documentation, Content Management System, cms, headless, javascript, node, react, nextjs
77
---
88

9-
Payload provides a variety of powerful [React Hooks](https://react.dev/reference/react-dom/hooks) that can be used within your own [Custom Components](./components), such as [Custom Fields](../fields/overview#custom-components). With them, you can interface with Payload itself to build just about any type of complex customization you can think of.
9+
Payload provides a variety of powerful [React Hooks](https://react.dev/reference/react-dom/hooks) that can be used within your own [Custom Components](../custom-components/overview), such as [Custom Fields](../fields/overview#custom-components). With them, you can interface with Payload itself to build just about any type of complex customization you can think of.
1010

1111
<Banner type="warning">
1212
**Reminder:**
13-
All Custom Components are [React Server Components](https://react.dev/reference/rsc/server-components) by default. Hooks, on the other hand, are only available in client-side environments. To use hooks, [ensure your component is a client component](./components#client-components).
13+
All Custom Components are [React Server Components](https://react.dev/reference/rsc/server-components) by default. Hooks, on the other hand, are only available in client-side environments. To use hooks, [ensure your component is a client component](../custom-components/overview#client-components).
1414
</Banner>
1515

1616
## useField
@@ -875,7 +875,7 @@ const Greeting: React.FC = () => {
875875

876876
## useConfig
877877

878-
Used to retrieve the Payload [Client Config](./components#accessing-the-payload-config).
878+
Used to retrieve the Payload [Client Config](../custom-components/overview#accessing-the-payload-config).
879879

880880
```tsx
881881
'use client'

0 commit comments

Comments
 (0)