|
1
|
--- |
|
2
|
sidebar_label: "Thumbnail" |
|
3
|
--- |
|
4
|
|
|
5
|
import { TypeList } from "docs-ui" |
|
6
|
|
|
7
|
export const metadata = { |
|
8
|
title: `Thumbnail - Admin Components`, |
|
9
|
} |
|
10
|
|
|
11
|
# {metadata.title} |
|
12
|
|
|
13
|
<Note> |
|
14
|
|
|
15
|
This component is available since Medusa [v2.21.0](https://github.com/medusajs/medusa/releases/tag/v2.21.0). |
|
16
|
|
|
17
|
</Note> |
|
18
|
|
|
19
|
The `Thumbnail` component shows a small image in a bordered box, falling back to a photo icon when there's no image. The Medusa Admin uses it next to product names in tables and lists. |
|
20
|
|
|
21
|
```tsx |
|
22
|
import { Thumbnail } from "@medusajs/dashboard/components" |
|
23
|
``` |
|
24
|
|
|
25
|
--- |
|
26
|
|
|
27
|
## Example |
|
28
|
|
|
29
|
Use `Thumbnail` in a [widget](!docs!/learn/fundamentals/admin/widgets) or [UI route](!docs!/learn/fundamentals/admin/ui-routes) to show a record's image: |
|
30
|
|
|
31
|
```tsx |
|
32
|
import { Thumbnail } from "@medusajs/dashboard/components" |
|
33
|
import { Text } from "@medusajs/ui" |
|
34
|
|
|
35
|
const ProductItem = ({ product }) => { |
|
36
|
return ( |
|
37
|
<div className="flex items-center gap-x-3"> |
|
38
|
<Thumbnail |
|
39
|
src={product.thumbnail} |
|
40
|
alt={product.title} |
|
41
|
size="small" |
|
42
|
/> |
|
43
|
<Text size="small">{product.title}</Text> |
|
44
|
</div> |
|
45
|
) |
|
46
|
} |
|
47
|
``` |
|
48
|
|
|
49
|
--- |
|
50
|
|
|
51
|
## Props |
|
52
|
|
|
53
|
The component accepts the `ThumbnailProps` type: |
|
54
|
|
|
55
|
<TypeList |
|
56
|
types={[ |
|
57
|
{ |
|
58
|
name: "src", |
|
59
|
type: "`string` \\| `null`", |
|
60
|
optional: true, |
|
61
|
description: `The image's URL. When you don't pass it, Medusa shows a photo icon as a placeholder.`, |
|
62
|
}, |
|
63
|
{ |
|
64
|
name: "alt", |
|
65
|
type: "`string`", |
|
66
|
optional: true, |
|
67
|
description: `The image's alternative text.`, |
|
68
|
}, |
|
69
|
{ |
|
70
|
name: "size", |
|
71
|
type: '`"small"` \\| `"base"`', |
|
72
|
optional: true, |
|
73
|
defaultValue: "base", |
|
74
|
description: `The thumbnail's size.`, |
|
75
|
}, |
|
76
|
]} |
|
77
|
/> |