Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ryohey/use-dialog-mui


https://github.com/ryohey/use-dialog-mui

Last synced: about 1 month ago
JSON representation

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