0.0.4 • Published 2 years ago

use-prompt-mui v0.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

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
}
0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago