--- layout: default title : Android Snackbars done right for the web. ---
Inspired by Android's very own Snackbar widget, SnackJS is an attempt to provide a minimal feedback notification in case of a web operation through a concise message and/or a single action response displayed at the bottom of the screen. For more information visit Google's Material Design - Snackbar & Toasts.
1. Clone the repository
{% highlight shell %} git clone https://github.com/achillesrasquinha/SnackJS.git {% endhighlight %}2. Install using npm
{% highlight shell %} npm install snackjs {% endhighlight %}3. Install using bower
{% highlight shell %} bower install snackjs {% endhighlight %}In your HTML file
{% highlight html %} ... ... {% endhighlight %}A template declaration would be as follows
{% highlight javascript %} var snack = Snack.make("For example,
{% highlight javascript %} // Message-Only Snack Snack.make("This is a Snack.").show(); // Message + Action Snack Snack.make("This is a Snack with an action.", { action : 'Okay', onAction: function ( ) { alert("Success!"); } }).show(); {% endhighlight %}Or maybe, a chain call
{% highlight javascript %} var snack = new Snack(); snack.message ("Luke, I'm your father.") .settings({ duration: Snack.LONG, hideOnClick: true }) .show(); {% endhighlight %}| Return | Method | Description |
|---|---|---|
| Snack | make(message, option) |
Creates a snackbar with message and options provided. |
| Snack | settings(option) |
Pass your options to settings to change them any time. |
| Snack | message(message) |
Update the Snack's message. |
| void | show() |
Display the Snack. |
| void | hide() |
Hide the Snack. |