• This repository has been archived on 10/Mar/2021
  • Stars
    star
    641
  • Rank 70,212 (Top 2 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 10 years ago
  • Updated almost 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Create Material Design snackbars and toasts with ease.

SnackbarJS

SnackbarJS is a lightweight and jQuery powered plugin made to work just like the tooltips in Bootstrap.

Include it in your html page with:

<head>
    <!-- core CSS of SnackbarJS, find it in /dist -->
    <link href=snackbar.min.css rel=stylesheet>
    <!-- the default theme of SnackbarJS, find it in /themes-css -->
    <link href=material.css rel=stylesheet>
</head>
<body>
    ...
    <!-- SnackbarJS, find it in /dist -->
    <script src=snackbar.min.js></script>
</body>

To use it in HTML:

<span data-toggle=snackbar data-content="This is my awesome snackbar!">Click me</span>

or with javascript:

$.snackbar({content: "This is my awesome snackbar!"});

Options

Following options are supported to customize look and behaviour:

var options =  {
    content: "Some text", // text of the snackbar
    style: "toast", // add a custom class to your snackbar
    timeout: 100, // time in milliseconds after the snackbar autohides, 0 is disabled
    htmlAllowed: true, // allows HTML as content value
    onClose: function(){ } // callback called when the snackbar gets closed.
}

$.snackbar(options);

Or in HTML:

<span data-toggle=snackbar
      data-content="Some text"
      data-style="toast"
      data-timeout="100"
      data-html-allowed="true">
Click me
</span>

Tip: SnackbarJS returns always a jQuery element which corresponds to the snackbar DOM element, you can use it to get the ID of the element, and then do other operations with it.

Heads up!: The onClose callback is not available using the HTML syntax.

Interact with snackbars

Once you have created a snackbar you can show, hide or toggle it with:

$("#snackbarid").snackbar("show");
$("#snackbarid").snackbar("hide");
$("#snackbarid").snackbar("toggle");

#snackbarid can be both the button with the data-toggle=snackbar attribute or the snackbar element. Calling it on a non-existing snackbar will create it before executing the specificed action.

Demo

To see SnackbarJS in action visit the demo page.

Browserify

This library is UMD compatible, so you can use it in this way:

var jquery = require('jquery');
require('snackbarjs');

var options =  {
    ...
}

jquery.snackbar(options);

More Repositories

1

react-resize-aware

β‡²πŸ‘ A simple React Hook which allows to listen the resize event of any target element when it changes sizes
JavaScript
490
star
2

dropdown.js

A dropdown plugin that does what you expect. (NEEDS MAINTAINER)
JavaScript
189
star
3

react-element-queries

🐣🐷 Conditionally render pieces of UI based on element queries.
JavaScript
72
star
4

skrollr-colors

skrollr-colors is a plugin for skrollr which allow you to use mixed colors formats in skrollr's keyframes.
JavaScript
52
star
5

node-red-matter

Create Virtual Devices with Ease for the Matter Protocol!
TypeScript
43
star
6

rpi4-docker-compose-home-assistant

Dockerfile
29
star
7

bootstrap-material-design

Redirect repository
HTML
23
star
8

gist-manager

UNMAINTAINED - View and create gists within Brackets editor
JavaScript
18
star
9

spectacle-image-slide

Show a slide with a big image and a title on top
JavaScript
16
star
10

ama

Ask Me Anything
14
star
11

netflix

Not associated with Netflix
JavaScript
14
star
12

brackets-upper-titlebar

Moves the titlebar of Brackets for linux on top of the window.
CSS
7
star
13

material-design-iconfont

Material Design iconic font
CSS
7
star
14

google-assistant-mac

🚨WORK IN PROGRESS 🚨 - Bring Google Assistant on your Mac, with a Siri-like interface.
JavaScript
6
star
15

bootstrap-material-datepicker

Datepicker for bootstrap-material
HTML
5
star
16

parallax-slideshow

Simple slideshow with Parallax effect
JavaScript
4
star
17

tado-clone

Tado app clone built with React Native and Expo - works with Home Assistant
JavaScript
4
star
18

ghat

A chat with GitHub integration.
CSS
3
star
19

digital-wall

React app to show informations on TV screen
JavaScript
3
star
20

raycast-toolkit

Utilities and Components to extend the Raycast Extensions API functionalities
TypeScript
3
star
21

FezVrasta.github.io

My portfolio
HTML
2
star
22

brackets-darkbar

Stupid extension to uniform the color of the main toolbar with the rest of Brackets.
JavaScript
2
star
23

react-axe-es

react-axe, with improved support for ES modules imports
JavaScript
2
star
24

nodebb-widget-steamserverstatus

NodeBB widget to provide informations about a server which supports Steam API.
JavaScript
2
star
25

nuget-publish

Publish npm packages to NuGet using package.json
JavaScript
1
star
26

webpack-context-relative-resolver

JavaScript
1
star
27

which-pm-runs-cli

Detects what package manager executes the process from CLI
JavaScript
1
star
28

eslint-plugin-no-iife

ESLint plugin to disallow IIFE
JavaScript
1
star
29

graphql-relay-cross-tab-sync

TypeScript
1
star