luna-modal
TypeScript icon, indicating that this package has built-in type declarations

1.2.2 • Public • Published

Luna Modal

Create modal dialogs.

Demo

https://luna.liriliri.io/?path=/story/modal

Install

Add the following script and style to your page.

<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/luna-modal/luna-modal.css" />
<script src="//cdn.jsdelivr.net/npm/luna-modal/luna-modal.js"></script>

You can also get it on npm.

npm install luna-modal --save
import 'luna-modal/luna-modal.css'
import LunaModal from 'luna-modal'

Usage

const container = document.getElementById('container')
const modal = new LunaModal(container, {
  title: 'This is the Title',
  content: 'This is the content.',
})
modal.show()

LunaModal.alert('This is the alert content.')

Configuration

  • content(string | HTMLElement): Modal content.
  • footer(string | HTMLElement): Modal footer.
  • showClose(boolean): Whether to show close button.
  • title(string): Modal title.
  • width(number): Modal width.

Api

hide(): void

Hide the modal.

show(): void

Show the modal.

static alert(msg: string): Promise

Like window.alert.

static confirm(msg: string): Promise

Like window.confirm.

static prompt(title?: string, defaultText?: string): Promise<null | string>

Like window.prompt.

static setContainer(container: HTMLElement): void

Set alert, prompt, confirm container, need to be called first.

Readme

Keywords

Package Sidebar

Install

npm i luna-modal

Weekly Downloads

74

Version

1.2.2

License

MIT

Unpacked Size

228 kB

Total Files

26

Last publish

Collaborators

  • surunzi