use-prompt-mui
v0.0.4
Published
Prompt Hooks for mui
Downloads
5
Readme
use-prompt-mui
React alternative to window.prompt() using MUI
Installation
npm install use-prompt-mui
Setup
<PromptProvider>
<App />
</PromptProvider>
usePrompt
const ExampleButton = () => {
const prompt = usePrompt()
return <button onClick={async () =>
const message = await prompt.show({
title: "Enter your message",
})
if (message !== null) {
console.log(message)
}
}>
Push me
</button>
}
API
show(options: PromptOptions): Promise<string | null>
interface PromptOptions {
title: string
message?: string
initialText?: string
okText?: string
cancelText?: string
}