Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ryohey/use-dialog-mui
https://github.com/ryohey/use-dialog-mui
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/ryohey/use-dialog-mui
- Owner: ryohey
- License: mit
- Created: 2022-08-27T05:41:06.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2022-08-27T05:41:50.000Z (about 2 years ago)
- Last Synced: 2024-09-17T17:28:50.261Z (about 2 months 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
}
```