https://github.com/ryohey/use-dialog-mui
https://github.com/ryohey/use-dialog-mui
Last synced: 14 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/ryohey/use-dialog-mui
- Owner: ryohey
- License: mit
- Created: 2022-08-27T05:41:06.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-08-27T05:41:50.000Z (almost 3 years ago)
- Last Synced: 2025-06-29T21:39:02.173Z (14 days ago)
- Language: TypeScript
- Size: 29.3 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# use-dialog-mui
React alternative to window.alert() using MUI
## Installation
```sh
npm install use-dialog-mui
```## Setup
```js
```
## useDialog
```jsx
const ExampleButton = () => {
const dialog = useDialog()
return
const result = await dialog.show({
title: "Do you want to save your changes?",
actions: [
{ title: localized("yes", "Yes"), key: "yes" },
{ title: localized("no", "No"), key: "no" },
{ title: localized("cancel", "Cancel"), key: "cancel" },
]
}) // returns "yes" | "no" | "cancel" | null
if (result === "yes") {
console.log("yay")
}
}>
Push me
}
```## API
### show(options: DialogOptions): Promise
```ts
interface DialogOptions {
title: string
message?: string
actions: DialogAction[]
}interface DialogAction {
title: string
key: Key
}
```