|
1
|
--- |
|
2
|
sidebar_label: "Two Column" |
|
3
|
--- |
|
4
|
|
|
5
|
export const metadata = { |
|
6
|
title: `Two 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:two-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 two columns of content. |
|
18
|
|
|
19
|
The Medusa Admin has pages with two columns 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 two columns of content, create the component `src/admin/layouts/two-column.tsx` with the following content: |
|
30
|
|
|
31
|
```tsx title="src/admin/layouts/two-column.tsx" |
|
32
|
export type TwoColumnLayoutProps = { |
|
33
|
firstCol: React.ReactNode |
|
34
|
secondCol: React.ReactNode |
|
35
|
} |
|
36
|
|
|
37
|
export const TwoColumnLayout = ({ |
|
38
|
firstCol, |
|
39
|
secondCol, |
|
40
|
}: TwoColumnLayoutProps) => { |
|
41
|
return ( |
|
42
|
<div className="flex flex-col gap-x-4 gap-y-3 xl:flex-row xl:items-start"> |
|
43
|
<div className="flex w-full flex-col gap-y-3"> |
|
44
|
{firstCol} |
|
45
|
</div> |
|
46
|
<div className="flex w-full max-w-[100%] flex-col gap-y-3 xl:mt-0 xl:max-w-[440px]"> |
|
47
|
{secondCol} |
|
48
|
</div> |
|
49
|
</div> |
|
50
|
) |
|
51
|
} |
|
52
|
``` |
|
53
|
|
|
54
|
The `TwoColumnLayout` accepts two props: |
|
55
|
|
|
56
|
- `firstCol` indicating the content of the first column. |
|
57
|
- `secondCol` indicating the content of the second column. |
|
58
|
|
|
59
|
--- |
|
60
|
|
|
61
|
## Example |
|
62
|
|
|
63
|
Use the `TwoColumnLayout` component in your UI routes that have two columns. For example: |
|
64
|
|
|
65
|
```tsx title="src/admin/routes/custom/page.tsx" highlights={[["9"]]} |
|
66
|
import { defineRouteConfig } from "@medusajs/admin-sdk" |
|
67
|
import { ChatBubbleLeftRight } from "@medusajs/icons" |
|
68
|
import { Container } from "../../components/container" |
|
69
|
import { Header } from "../../components/header" |
|
70
|
import { TwoColumnLayout } from "../../layouts/two-column" |
|
71
|
|
|
72
|
const CustomPage = () => { |
|
73
|
return ( |
|
74
|
<TwoColumnLayout |
|
75
|
firstCol={ |
|
76
|
<Container> |
|
77
|
<Header title="First Column" /> |
|
78
|
</Container> |
|
79
|
} |
|
80
|
secondCol={ |
|
81
|
<Container> |
|
82
|
<Header title="Second Column" /> |
|
83
|
</Container> |
|
84
|
} |
|
85
|
/> |
|
86
|
) |
|
87
|
} |
|
88
|
|
|
89
|
export const config = defineRouteConfig({ |
|
90
|
label: "Custom", |
|
91
|
icon: ChatBubbleLeftRight, |
|
92
|
}) |
|
93
|
|
|
94
|
export default CustomPage |
|
95
|
``` |
|
96
|
|
|
97
|
This UI route also uses [Container](../../guides/container/page.mdx) and [Header](../../guides/header/page.mdx) custom components. |