@saas-ui/modals-provider
TypeScript icon, indicating that this package has built-in type declarations

1.0.0-alpha.0 • Public • Published

@saas-ui/modals-provider

UI library agnostic React modals manager.

Installation

$ yarn add @saas-ui/modals-provider

#or

$ npm i @saas-ui/modals-provider  --save

Usage

Add the ModalProvider to your app.

export const {ModalsProvider, useModals} = createModals({
  modals: {
    alert: AlertDialog,
    confirm: ConfirmDialog,
  }
})

export default App() {
  return (
    <ModalsProvider>
      {children}
    </ModalsProvider>
  )
}

Open a modal

import { useModals } from './modals-provider'

function MyComponent() {
  const modals = useModals()

  modals.open(MyModal, {
    title: 'My modal',
  })
}

Open a confirm dialog

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

Docs

https://www.saas-ui.dev/docs/overlay/modals-manager

Source

https://github.com/saas-js/saas-ui/tree/next/packages/saas-ui-modals-provider

License

MIT - Appulse Software

Package Sidebar

Install

npm i @saas-ui/modals-provider

Homepage

saas-ui.dev/

Weekly Downloads

24

Version

1.0.0-alpha.0

License

MIT

Unpacked Size

63.8 kB

Total Files

13

Last publish

Collaborators

  • eelcow