|
1
|
--- |
|
2
|
sidebar_label: "Single Column" |
|
3
|
--- |
|
4
|
|
|
5
|
export const metadata = { |
|
6
|
title: `Single Column Layout - Admin Components`, |
|
7
|
} |
|
8
|
|
|
9
|
# {metadata.title} |
|
10
|
|
|
11
|
<Note title="Archived" type="warning"> |
|
12
|
|
|
13
|
Medusa exports a `LayoutComposer` component from the `@medusajs/dashboard` package since [v2.21.0](https://github.com/medusajs/medusa/releases/tag/v2.21.0). Use it with the `core:single-column` layout instead of building your own layout, as explained in the [LayoutComposer documentation](../../layouts/layout-composer/page.mdx). This guide is kept for reference only. |
|
14
|
|
|
15
|
</Note> |
|
16
|
|
|
17
|
In this guide, you'll learn how to create a layout component that matches the Medusa Admin's design conventions for pages with a single column of content. |
|
18
|
|
|
19
|
The Medusa Admin has pages with a single column of content. |
|
20
|
|
|
21
|
<Note> |
|
22
|
|
|
23
|
This doesn't include the sidebar, only the main content. |
|
24
|
|
|
25
|
</Note> |
|
26
|
|
|
27
|
 |
|
28
|
|
|
29
|
To create a layout that you can use in UI routes to support one column of content, create the component `src/admin/layouts/single-column.tsx` with the following content: |
|
30
|
|
|
31
|
```tsx title="src/admin/layouts/single-column.tsx" |
|
32
|
export type SingleColumnLayoutProps = { |
|
33
|
children: React.ReactNode |
|
34
|
} |
|
35
|
|
|
36
|
export const SingleColumnLayout = ({ children }: SingleColumnLayoutProps) => { |
|
37
|
return ( |
|
38
|
<div className="flex flex-col gap-y-3"> |
|
39
|
{children} |
|
40
|
</div> |
|
41
|
) |
|
42
|
} |
|
43
|
``` |
|
44
|
|
|
45
|
The `SingleColumnLayout` accepts the content in the `children` props. |
|
46
|
|
|
47
|
--- |
|
48
|
|
|
49
|
## Example |
|
50
|
|
|
51
|
Use the `SingleColumnLayout` component in your UI routes that have a single column. For example: |
|
52
|
|
|
53
|
```tsx title="src/admin/routes/custom/page.tsx" highlights={[["9"]]} |
|
54
|
import { defineRouteConfig } from "@medusajs/admin-sdk" |
|
55
|
import { ChatBubbleLeftRight } from "@medusajs/icons" |
|
56
|
import { Container } from "../../components/container" |
|
57
|
import { SingleColumnLayout } from "../../layouts/single-column" |
|
58
|
import { Header } from "../../components/header" |
|
59
|
|
|
60
|
const CustomPage = () => { |
|
61
|
return ( |
|
62
|
<SingleColumnLayout> |
|
63
|
<Container> |
|
64
|
<Header title="Custom Page" /> |
|
65
|
</Container> |
|
66
|
</SingleColumnLayout> |
|
67
|
) |
|
68
|
} |
|
69
|
|
|
70
|
export const config = defineRouteConfig({ |
|
71
|
label: "Custom", |
|
72
|
icon: ChatBubbleLeftRight, |
|
73
|
}) |
|
74
|
|
|
75
|
export default CustomPage |
|
76
|
``` |
|
77
|
|
|
78
|
This UI route also uses a [Container](../../guides/container/page.mdx) and a [Header](../../guides/header/page.mdx) custom components. |