use-prompt-mui
TypeScript icon, indicating that this package has built-in type declarations

0.0.4 • Public • Published

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
}

Readme

Keywords

none

Package Sidebar

Install

npm i use-prompt-mui

Weekly Downloads

1

Version

0.0.4

License

MIT

Unpacked Size

10.6 kB

Total Files

21

Last publish

Collaborators

  • ryohey