|
1
|
--- |
|
2
|
sidebar_label: "Container" |
|
3
|
--- |
|
4
|
|
|
5
|
export const metadata = { |
|
6
|
title: `Container - Admin Components`, |
|
7
|
} |
|
8
|
|
|
9
|
# {metadata.title} |
|
10
|
|
|
11
|
In this guide, you'll learn how to create a container component that matches the Medusa Admin's design conventions. |
|
12
|
|
|
13
|
The Medusa Admin wraps each section of a page in a container. |
|
14
|
|
|
15
|
 |
|
16
|
|
|
17
|
To create a component that uses the same container styling in your widgets or UI routes, create the file `src/admin/components/container.tsx` with the following content: |
|
18
|
|
|
19
|
```tsx |
|
20
|
import { |
|
21
|
Container as UiContainer, |
|
22
|
clx, |
|
23
|
} from "@medusajs/ui" |
|
24
|
|
|
25
|
type ContainerProps = React.ComponentProps<typeof UiContainer> |
|
26
|
|
|
27
|
export const Container = (props: ContainerProps) => { |
|
28
|
return ( |
|
29
|
<UiContainer {...props} className={clx( |
|
30
|
"divide-y p-0", |
|
31
|
props.className |
|
32
|
)} /> |
|
33
|
) |
|
34
|
} |
|
35
|
``` |
|
36
|
|
|
37
|
The `Container` component re-uses the component from the [Medusa UI package](!ui!/components/container) and applies to it classes to match the Medusa Admin's design conventions. |
|
38
|
|
|
39
|
--- |
|
40
|
|
|
41
|
## Example |
|
42
|
|
|
43
|
Use that `Container` component in any widget or UI route. |
|
44
|
|
|
45
|
For example, create the widget `src/admin/widgets/product-widget.tsx` with the following content: |
|
46
|
|
|
47
|
```tsx title="src/admin/widgets/product-widget.tsx" |
|
48
|
import { defineWidgetConfig } from "@medusajs/admin-sdk" |
|
49
|
import { Container } from "../components/container" |
|
50
|
import { Header } from "../components/header" |
|
51
|
|
|
52
|
const ProductWidget = () => { |
|
53
|
return ( |
|
54
|
<Container> |
|
55
|
<Header title="Product Widget" /> |
|
56
|
</Container> |
|
57
|
) |
|
58
|
} |
|
59
|
|
|
60
|
export const config = defineWidgetConfig({ |
|
61
|
zone: "product.details", |
|
62
|
}) |
|
63
|
|
|
64
|
export default ProductWidget |
|
65
|
``` |
|
66
|
|
|
67
|
This widget also uses a [Header](../header/page.mdx) custom component. |