@@ -3,9 +3,6 @@ description: Display custom alert, confirmation, or prompt screens in MetaMask.
3
3
sidebar_position : 2
4
4
---
5
5
6
- import Tabs from "@theme/Tabs ";
7
- import TabItem from "@theme/TabItem ";
8
-
9
6
# Dialogs
10
7
11
8
You can display a dialog in the MetaMask UI using the
@@ -38,9 +35,6 @@ To display an alert that can only be acknowledged, call
38
35
[ ` snap_dialog ` ] ( ../../reference/snaps-api.md#snap_dialog ) with ` type: "alert" ` .
39
36
The following example displays custom UI that alerts the user when something happens in the system:
40
37
41
- <Tabs >
42
- <TabItem value =" JSX " >
43
-
44
38
``` tsx title="index.tsx"
45
39
import { Box , Text , Heading } from " @metamask/snaps-sdk/jsx" ;
46
40
@@ -60,30 +54,6 @@ await snap.request({
60
54
// Code that should execute after the alert has been acknowledged.
61
55
```
62
56
63
- </TabItem >
64
- <TabItem value =" Functions " deprecated >
65
-
66
- ``` javascript title="index.js"
67
- import { panel , text , heading } from " @metamask/snaps-sdk"
68
-
69
- await snap .request ({
70
- method: " snap_dialog" ,
71
- params: {
72
- type: " alert" ,
73
- content: panel ([
74
- heading (" Something happened in the system" ),
75
- text (" The thing that happened is..." ),
76
- ]),
77
- },
78
- })
79
-
80
- // Code that should execute after the alert has been acknowledged.
81
- ```
82
-
83
- </TabItem >
84
- </Tabs >
85
-
86
-
87
57
<p align =" center " >
88
58
<img src={require("../../assets/alert-dialog.png").default} alt="Alert dialog example" width="360px" style={{border: "1px solid #DCDCDC"}} />
89
59
</p >
@@ -95,9 +65,6 @@ To display a confirmation that can be accepted or rejected, call
95
65
The following example displays custom UI that asks the user to confirm whether they would like to
96
66
take an action:
97
67
98
- <Tabs >
99
- <TabItem value =" JSX " >
100
-
101
68
``` tsx title="index.tsx"
102
69
import { Box , Text , Heading } from " @metamask/snaps-sdk/jsx" ;
103
70
@@ -119,31 +86,6 @@ if (result === true) {
119
86
}
120
87
```
121
88
122
- </TabItem >
123
- <TabItem value =" Functions " deprecated >
124
-
125
- ``` javascript title="index.js"
126
- import { panel , text , heading } from " @metamask/snaps-sdk"
127
-
128
- const result = await snap .request ({
129
- method: " snap_dialog" ,
130
- params: {
131
- type: " confirmation" ,
132
- content: panel ([
133
- heading (" Would you like to take the action?" ),
134
- text (" The action is..." ),
135
- ]),
136
- },
137
- })
138
-
139
- if (result === true ) {
140
- // Do the action.
141
- }
142
- ```
143
-
144
- </TabItem >
145
- </Tabs >
146
-
147
89
<p align =" center " >
148
90
<img src={require("../../assets/confirmation-dialog.png").default} alt="Confirmation dialog example" width="360px" style={{border: "1px solid #DCDCDC"}} />
149
91
</p >
@@ -156,9 +98,6 @@ Prompt dialogs also accept a `placeholder` value that displays in the input fiel
156
98
157
99
The following example displays custom UI that prompts the user to enter a wallet address:
158
100
159
- <Tabs >
160
- <TabItem value =" JSX " >
161
-
162
101
``` tsx title="index.tsx"
163
102
import { Box , Text , Heading } from " @metamask/snaps-sdk/jsx" ;
164
103
@@ -179,30 +118,6 @@ const walletAddress = await snap.request({
179
118
// walletAddress will be a string containing the address entered by the user.
180
119
```
181
120
182
- </TabItem >
183
- <TabItem value =" Functions " deprecated >
184
-
185
- ``` javascript title="index.js"
186
- import { panel , text , heading } from " @metamask/snaps-sdk"
187
-
188
- const walletAddress = await snap .request ({
189
- method: " snap_dialog" ,
190
- params: {
191
- type: " prompt" ,
192
- content: panel ([
193
- heading (" What is the wallet address?" ),
194
- text (" Please enter the wallet address to be monitored" ),
195
- ]),
196
- placeholder: " 0x123..." ,
197
- },
198
- })
199
-
200
- // walletAddress will be a string containing the address entered by the user.
201
- ```
202
-
203
- </TabItem >
204
- </Tabs >
205
-
206
121
<p align =" center " >
207
122
<img src={require("../../assets/prompt-dialog.png").default} alt="Prompt dialog example" width="360px" style={{border: "1px solid #DCDCDC"}} />
208
123
</p >
0 commit comments