UI library agnostic React modals manager.
$ yarn add @saas-ui/modals-provider
#or
$ npm i @saas-ui/modals-provider --save
export const {ModalsProvider, useModals} = createModals({
modals: {
alert: AlertDialog,
confirm: ConfirmDialog,
}
})
export default App() {
return (
<ModalsProvider>
{children}
</ModalsProvider>
)
}
import { useModals } from './modals-provider'
function MyComponent() {
const modals = useModals()
modals.open(MyModal, {
title: 'My modal',
})
}
import { useModals } from './modals-provider'
function MyComponent() {
const modals = useModals()
modals.confirm({
title: 'Delete user',
body: 'Are you sure you want to delete this user?'
onConfirm: () => //delete user
})
}
https://www.saas-ui.dev/docs/overlay/modals-manager
https://github.com/saas-js/saas-ui/tree/next/packages/saas-ui-modals-provider
MIT - Appulse Software