1 ---
2 sidebar_label: "Section Row"
3 ---
4
5 import { TypeList } from "docs-ui"
6
7 export const metadata = {
8 title: `Section Row - Admin Components`,
9 }
10
11 # {metadata.title}
12
13 <Note title="Archived" type="warning">
14
15 Medusa exports a `SectionRow` component from the `@medusajs/dashboard` package since [v2.21.0](https://github.com/medusajs/medusa/releases/tag/v2.21.0). Use [the exported component](../../components/section-row/page.mdx) instead of building your own. This guide is kept for reference only.
16
17 </Note>
18
19 In this guide, you'll learn how to create a section row component that matches the Medusa Admin's design conventions.
20
21 The Medusa Admin often shows information in rows of label-values, such as when showing a product's details.
22
23 ![Example of a section row in the Medusa Admin](https://res.cloudinary.com/dza7lstvk/image/upload/v1728292781/Medusa%20Resources/section-row_kknbnw.png)
24
25 To create a component that shows information in the same structure, create the file `src/admin/components/section-row.tsx` with the following content:
26
27 ```tsx title="src/admin/components/section-row.tsx"
28 import { Text, clx } from "@medusajs/ui"
29
30 export type SectionRowProps = {
31 title: string
32 value?: React.ReactNode | string | null
33 actions?: React.ReactNode
34 }
35
36 export const SectionRow = ({ title, value, actions }: SectionRowProps) => {
37 const isValueString = typeof value === "string" || !value
38
39 return (
40 <div
41 className={clx(
42 `text-ui-fg-subtle grid grid-cols-2 items-center px-6 py-4`,
43 {
44 "grid-cols-[1fr_1fr_28px]": !!actions,
45 }
46 )}
47 >
48 <Text size="small" weight="plus" leading="compact">
49 {title}
50 </Text>
51
52 {isValueString ? (
53 <Text
54 size="small"
55 leading="compact"
56 className="whitespace-pre-line text-pretty"
57 >
58 {value ?? "-"}
59 </Text>
60 ) : (
61 <div className="flex flex-wrap gap-1">{value}</div>
62 )}
63
64 {actions && <div>{actions}</div>}
65 </div>
66 )
67 }
68 ```
69
70 The `SectionRow` component shows a title and a value in the same row.
71
72 It accepts the following props:
73
74 <TypeList
75 types={[
76 {
77 name: "title",
78 type: "`string`",
79 optional: false,
80 description: "The title to show on the left side."
81 },
82 {
83 name: "value",
84 type: "`React.ReactNode` \\| `string` \\| `null`",
85 optional: true,
86 description: "The value to show on the right side."
87 },
88 {
89 name: "actions",
90 type: "`React.ReactNode`",
91 optional: true,
92 description: "The actions to show at the end of the row."
93 }
94 ]}
95 />
96
97 ---
98
99 ## Example
100
101 Use the `SectionRow` component in any widget or UI route.
102
103 For example, create the widget `src/admin/widgets/product-widget.tsx` with the following content:
104
105 ```tsx title="src/admin/widgets/product-widget.tsx"
106 import { defineWidgetConfig } from "@medusajs/admin-sdk"
107 import { Container } from "../components/container"
108 import { Header } from "../components/header"
109 import { SectionRow } from "../components/section-row"
110
111 const ProductWidget = () => {
112 return (
113 <Container>
114 <Header title="Product Widget" />
115 <SectionRow title="Name" value="John" />
116 </Container>
117 )
118 }
119
120 export const config = defineWidgetConfig({
121 zone: "product.details",
122 })
123
124 export default ProductWidget
125 ```
126
127 This widget also uses the [Container](../../guides/container/page.mdx) and [Header](../../guides/header/page.mdx) custom component.