All Projects → rfoel → Bulma Toast

rfoel / Bulma Toast

Licence: mit
Bulma's pure JavaScript extension to display toasts

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Bulma Toast

Laravel 8 Simple Cms
Laravel 8 content management system for starters.
Stars: ✭ 444 (+377.42%)
Mutual labels:  hacktoberfest, bulma
Toast
A JavaScript free toast library for Blazor and Razor Component applications
Stars: ✭ 296 (+218.28%)
Mutual labels:  hacktoberfest, toast
Burnttoast
Module for creating and displaying Toast Notifications on Microsoft Windows 10.
Stars: ✭ 796 (+755.91%)
Mutual labels:  hacktoberfest, toast
Bulma Admin Dashboard Template
🐝 Free admin dashboard template with bulma css
Stars: ✭ 327 (+251.61%)
Mutual labels:  hacktoberfest, bulma
Ayudapy
Platform to help people help people
Stars: ✭ 79 (-15.05%)
Mutual labels:  hacktoberfest, bulma
Cssbuttons
🚀 Pure HTML & CSS Buttons For Web Development
Stars: ✭ 91 (-2.15%)
Mutual labels:  hacktoberfest
Nifi Registry
Apache NiFi Registry
Stars: ✭ 91 (-2.15%)
Mutual labels:  hacktoberfest
Evennia
Python MUD/MUX/MUSH/MU* development system
Stars: ✭ 1,309 (+1307.53%)
Mutual labels:  hacktoberfest
Modulesync
Synchronize common files across your Git repositories.
Stars: ✭ 91 (-2.15%)
Mutual labels:  hacktoberfest
Atox
Reasonable Tox client for Android
Stars: ✭ 90 (-3.23%)
Mutual labels:  hacktoberfest
Pywizlight
A python connector for WiZ light bulbs (e.g SLV Play)
Stars: ✭ 92 (-1.08%)
Mutual labels:  hacktoberfest
Editor
Editor/IDE for Vega and Vega-Lite
Stars: ✭ 92 (-1.08%)
Mutual labels:  hacktoberfest
Haskell
Stars: ✭ 91 (-2.15%)
Mutual labels:  hacktoberfest
Binarykit
💾🔍🧮 BinaryKit helps you to break down binary data into bits and bytes, easily access specific parts and write data to binary.
Stars: ✭ 92 (-1.08%)
Mutual labels:  hacktoberfest
Vis Network
💫 Display dynamic, automatically organised, customizable network views.
Stars: ✭ 1,311 (+1309.68%)
Mutual labels:  hacktoberfest
Tutorialdb
A search 🔎 engine for programming/dev tutorials, See it in action 👉
Stars: ✭ 93 (+0%)
Mutual labels:  hacktoberfest
Hapistrano
Deploy tool for Haskell applications, like Capistrano for Rails
Stars: ✭ 91 (-2.15%)
Mutual labels:  hacktoberfest
Dockerfile Image Update
A tool that helps you get security patches for Docker images into production as quickly as possible without breaking things
Stars: ✭ 92 (-1.08%)
Mutual labels:  hacktoberfest
Prisma Docs Generator
Prisma generator for automatically generating documentation reference from the Prisma schema.
Stars: ✭ 91 (-2.15%)
Mutual labels:  hacktoberfest
Ccsearch Browser Extension
Cross-Browser extension to search, filter and use images in the public domain and under Creative Commons licenses.
Stars: ✭ 92 (-1.08%)
Mutual labels:  hacktoberfest

bulma-toast

npm version Publish

Bulma's pure JavaScript extension to display toasts. Basically a Bulma's notification implemented as a toast plugin.

Demo

Bulma Toast

Options

The plugin comes with the following options:

  • message: The actual message to be displayed. It can be a string, a template string, or a DOM node. See examples. This is required.
  • type: Essentially a Bulma's css class. It can be is-primary, is-link, is-info, is-success, is-warning, is-danger, or any other custom class. Default is a whitesmoke background with dark text as shown here.
  • duration: Duration of the notification in milliseconds. Default is 2000 milliseconds.
  • position: Position where the notification will be shown. The default is top-right, so if you want it to be on the top-left just add top-left to this option. The available options are: top-left, top-center, top-right, center, bottom-left, bottom-center, and bottom-right.
  • dismissible: Whether the notification will have a close button or not. Default is false.
  • pauseOnHover: Pauses delay when hovering the notification. Default is false.
  • closeOnClick: Dismisses the notification when clicked. Default is true.
  • opacity: The notification's container opacity. Default is 1.
  • animate: See here. Default is no animations.

Install

  npm install bulma-toast

or

  yarn add bulma-toast

Quick Start

  1. Link to bulma-toast.min.js
<script src="bulma-toast.min.js"></script>
  1. Use bulma-toast to display a toast
bulmaToast.toast({ message: 'Hello There' })
bulmaToast.toast({ message: 'General Kenobi', type: 'is-danger' })

ES Modules

// Import the toast function
import * as bulmaToast from 'bulma-toast'
// Or use
// import { toast as superToast } from 'bulma-toast'
// to rename your import

toast({
  message: 'Hello There',
  type: 'is-success',
  dismissible: true,
  animate: { in: 'fadeIn', out: 'fadeOut' },
})

Default config

A simple default object to prevent errors. Your options will be merged with these and the defaults will be used if the fields are not provided.

{
  "duration": 2000,
  "position": "top-right",
  "closeOnClick": true,
  "opacity": 1,
  "single": false,
  "offsetTop": 0,
  "offsetBottom": 0,
  "offsetLeft": 0,
  "offsetRight": 0
}

The default config can be updated using the funcion setDefaults. Also, it's possible to reset to the default config using resetDefaults

bulmaToast.setDefaults({
  duration: 1000,
  position: 'top-left',
  closeOnClick: false,
})

Change document context

bulmaToast.setDoc(window.document)

This can be changed before each toast call and can be set to eny element.

Animate

Bulma Toast supports animate.css (and maybe others?). You MUST include animate.css on your document's <head>

<head>
  <link rel="stylesheet" href="animate.min.css" />
  <!-- or -->
  <link
    rel="stylesheet"
    href="https://cdn.jsdelivr.net/npm/[email protected]/animate.min.css"
  />
  <!-- or -->
  <link
    rel="stylesheet"
    href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.0.0/animate.min.css"
  />
</head>

Accepts a object with in and out with css classes to add animations. Using Animate.css you would pass a object like this:

  {
    message: "I'm animated! Yay!",
    duration: 2000,
    position: "top-right",
    animate: { in: 'fadeIn', out: 'fadeOut' }
  }

Warning: Don't use opacity when using animations. Some of them use the opacity property like fade in and fade out.

Examples

import { toast } from 'bulma-toast'

toast({
  message: 'Hello There',
  type: 'is-success',
  dismissible: true,
  pauseOnHover: true,
})

toast({
  message: '<h1>LOOK HERE</h1>',
  type: 'is-danger',
  dismissible: true,
  pauseOnHover: true,
  animate: { in: 'fadeIn', out: 'fadeOut' },
})

const myMessage = `It's ${new Date().toDateString()}`

toast({
  message: myMessage,
  type: 'is-primary',
  position: 'center',
  closeOnClick: true,
  pauseOnHover: true,
  opacity: 0.8,
})

const elm = document.createElement('a')
elm.text = 'Visit my website!'
elm.href = 'https://rfoel.com'

toast({
  message: elm,
  type: 'is-warning',
  position: 'center',
  closeOnClick: true,
  pauseOnHover: true,
  animate: { in: 'fadeIn', out: 'fadeOut' },
})

Contributing

Issues and pull requests are welcome.

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].