Notify your users when actions succeed, fail, require further attention, or trigger any other information that the user needs to know by using the Snackbar component.
The Snackbar component, available free in Backendless Marketplace, lets you display simple error, success, info, and warning notifications to your UI.
These notifications can take multiple preset forms, or can be customized using Extensions to match your application’s styles. The notifications can also be set to hide at any interval, or can require user action to remove.
Installing custom components from Backendless Marketplace is super easy. First, in UI Builder, select the Components tab.
There, you will see a button labeled Install Component. This will take you to the library of components available in the Marketplace.
When you click Install Component, you will open a list of available UI Components to install.
Select the component you want and click Install.
When you return to the User Interface tab, you will see a new section added to your toolkit on the right-hand side called Custom Components.
You can then simply drag the component onto your canvas just like any other UI Component.
How the Snackbar Component Works
When added to your app, the Snackbar component offers several basic functions out of the box.
First, you have the ability to set whether the Snackbar will hide automatically or not. If you choose for the item to hide, you can also set the amount of time it will remain visible before hiding.
Next, you can choose from one of five different Snackbar types: default, info, success, warning, and error. These each have preset styles that can be easily customized using Extensions.
You can either hard-code the content of the Snackbar, or you can set it using Codeless logic. In order to access the Codeless block for a Snackbar component, you must give the component an ID in UI Builder.
Below you’ll see the logic used for the Snackbar example above.
You can choose to include an Action with the Snackbar, as we did with the warning snack in the example. You can also choose to hide the close “x” if you want to ensure the snack stays open until it hides.
Finally, using the toolkit in UI Builder, you can choose the location of each snack. You can choose both the horizontal alignment (right, center, left) and vertical position (top, center, bottom).
Available Options and What They Mean
Once you have placed your component, when you select it, you will see all of the available options (properties) for the component in the toolkit area. These are the default settings for the component that you can easily adjust.
Each of the available properties are described in the table below. For more information, such as Theme styles and event handlers, visit the Snackbar GitHub repo.
This is a handler that controls visibility of the close button.
This is a handler that controls visibility of the action button.
Action Content Logic
This is a handler to set the text of the action button.
Snackbar Content Logic
This is a handler to set the text of the snackbar.
This is a handler that controls autohiding.
This is a handler that sets the time when snackbar will be hidden.
[top, center, bottom]
This is a handler that sets the vertical position of snackbar.
[right, center, left]
This is a handler that sets the horizontal position of snackbar.
[default, info, success, warning, error]
This is a handler to set the type of the snackbar.
This is a handler to set the number of maximum visible snackbars.
When you click on the Logic icon or tab for the component, you will see the modifiable event handlers, just as you would with a standard component. However, the main logic for the component – the logic that makes it work – is hidden to protect it from accidentally being broken.
Additionally, in the Logic area, you will also find all available data binding properties.
That’s it! Ready to try it for yourself?
The Snackbar component is one of many custom components available now in Backendless Marketplace, completely free!
Start Building Your Perfect UI
Start your free 30-day trial today to get access to the full library of UI components, plus the most powerful Codeless backend available. What are you waiting for?
A snackbar or “toast” element is a message displayed to the user, usually on a temporary basis over a few seconds. It’s great for alerting the user to something without requiring any action. Think of a success message, a confirmation, or an error alert of some kind.