|
1
|
--- |
|
2
|
sidebar_label: "Display ID" |
|
3
|
--- |
|
4
|
|
|
5
|
import { TypeList } from "docs-ui" |
|
6
|
|
|
7
|
export const metadata = { |
|
8
|
title: `DisplayId - 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 `DisplayId` component shows the last seven characters of an ID, prefixed by a hash. When the user hovers over it, Medusa shows the full ID in a tooltip, and when the user clicks it, Medusa copies the full ID to the clipboard and shows a success toast. |
|
20
|
|
|
21
|
```tsx |
|
22
|
import { DisplayId } from "@medusajs/dashboard/components" |
|
23
|
``` |
|
24
|
|
|
25
|
--- |
|
26
|
|
|
27
|
## Example |
|
28
|
|
|
29
|
Use `DisplayId` in a [widget](!docs!/learn/fundamentals/admin/widgets) or [UI route](!docs!/learn/fundamentals/admin/ui-routes) to show a record's ID in a compact way: |
|
30
|
|
|
31
|
```tsx |
|
32
|
import { |
|
33
|
DisplayId, |
|
34
|
SectionRow, |
|
35
|
} from "@medusajs/dashboard/components" |
|
36
|
|
|
37
|
const BrandIdRow = ({ brand }) => { |
|
38
|
return ( |
|
39
|
<SectionRow |
|
40
|
title="ID" |
|
41
|
value={<DisplayId id={brand.id} />} |
|
42
|
/> |
|
43
|
) |
|
44
|
} |
|
45
|
``` |
|
46
|
|
|
47
|
--- |
|
48
|
|
|
49
|
## Props |
|
50
|
|
|
51
|
The component accepts the `DisplayIdProps` type: |
|
52
|
|
|
53
|
<TypeList |
|
54
|
types={[ |
|
55
|
{ |
|
56
|
name: "id", |
|
57
|
type: "`string`", |
|
58
|
optional: false, |
|
59
|
description: |
|
60
|
"The ID to show. Medusa shows only its last seven characters, but it copies the full ID.", |
|
61
|
}, |
|
62
|
{ |
|
63
|
name: "className", |
|
64
|
type: "`string`", |
|
65
|
optional: true, |
|
66
|
description: `Additional CSS classes to add to the ID's element.`, |
|
67
|
}, |
|
68
|
]} |
|
69
|
/> |