DEV Community

Takane Ichinose
Takane Ichinose

Posted on

3 1

Vanilla JS Responsive Message Box with Javascript Class

This Message Box is inspired by material design's toast message.

I used the VanillaJS (native Javascript) Class to implement the message box. This may not work on older browsers, due to compatibility issue with native class.

Usage:

  1. Create MessageBox class instance: let msg = new MessageBox("#id", option)
  2. Available options (type: Object): a. closeTime // Time before the message box closes (In milliseconds). 0 for persistent b. hideCloseButton // To hide the close button.
  3. Call the "show" method to show the dialog box. Params: message // The message that will appear on the message box label // The label of the close button (default is "CLOSE"). callback // Callback function

Top comments (0)

SurveyJS custom survey software

JavaScript Form Builder UI Component

Generate dynamic JSON-driven forms directly in your JavaScript app (Angular, React, Vue.js, jQuery) with a fully customizable drag-and-drop form builder. Easily integrate with any backend system and retain full ownership over your data, with no user or form submission limits.

Learn more

Best practices for optimal infrastructure performance with Magento

Running a Magento store? Struggling with performance bottlenecks? Join us and get actionable insights and real-world strategies to keep your store fast and reliable.

Tune in to the full event

DEV is partnering to bring live events to the community. Join us or dismiss this billboard if you're not interested. ❤️