1 import { HookValues } from "@/components/HookValues"
2 import { ComponentReference } from "@/components/ComponentReference"
3 import { ComponentExample } from "@/components/ComponentExample"
4
5 export const metadata = {
6 title: `usePrompt`,
7 }
8
9 # {metadata.title}
10
11
12
13 This hook returns a function that prompts the user to confirm an action.
14
15 In this guide, you'll learn how to use the `usePrompt` hook.
16
17 <ComponentExample name="use-prompt-demo" />
18
19 ## Usage
20
21 ```tsx
22 import { usePrompt } from "@medusajs/ui"
23 ```
24
25 ```tsx
26 const dialog = usePrompt()
27 const actionFunction = async () => {
28 const confirmed = await dialog({
29 title: "Are you sure?",
30 description: "Please confirm this action",
31 })
32 }
33 ```
34
35 ---
36
37 ## API Reference
38
39 ### usePrompt Return Value
40
41 <HookValues hook="usePromptReturn" />
42
43 ### Returned Dialog Parameters
44
45 The dialog function returned by `usePrompt` accepts an object having the following properties:
46
47 <ComponentReference mainComponent="RenderPrompt" />
48
49 ### Dialog Return Value
50
51 The dialog function returns a Promise that resolves to a boolean indicating whether the user confirmed the action.
52
53 ---
54
55 ## Examples
56
57 ### Prompt with Verification Text
58
59 <ComponentExample name="use-prompt-verification" hideFeedback />