Skip to main content
Give us your valuable feedback

It will help us understand how we can serve you better

Give feedback

Components

Snackbar

Snackbar displays informative text

banner-Snackbar
Component Status Details

Status component contains a list of checks and completeness that has been tested and owned by each component

check-list-icon We don't use color as the only visual tool to convey information.
check-list-icon The component’s structure and properties include relevant options such as variant, style, size, orientation, optional iconography, decorations, selection, error state, etc.check-list-icon The title is the component name that uses the frame base component template.check-list-icon The base component name contains: .Base & "Component Name" if there is more than one.check-list-icon All component properties use the Legion foundation.
check-list-icon We can change all the parts that are connected to the component base.check-list-icon The inside of the base component remains connected to the master component.check-list-icon All variant options are not damaged when we change from one to another.check-list-icon Overriding changes to components will not reset other variants.
check-list-icon Component's already has component specs documentation.

Status

Resources

Upcoming Upcoming

Snackbars notify users of processes that have been or will be performed by the app. They appear temporarily, towards the bottom of the screen. They must not interfere with the user experience, and they do not require user input to disappear.

usage snackbar

Variants & Themes

Legion has 4 variants for snackbar :

  1. Title
  2. Description
  3. Action Text
  4. Icon / Avatar

Legion has 5 themes for snackbar :

  1. Basic / Normal Theme
  2. Error Theme
  3. Warning Theme
  4. Success Theme
  5. Info Theme

Usage

To implement a snackbar, you can create SnackbarHost, which includes a LgnSnackbarHostState property. LgnSnackbarHostState provides access to the showSnackbar() function which you can use to display LgnSnackbar.

This suspending function requires a CoroutineScope such as with using rememberCoroutineScope — and can be called in response to UI events to show a LgnSnackBar within Scaffold.



Normal Snackbar

val scope = rememberCourotineScope()
val snackbarHostState = remember { LgnSnackbarHostState() }
Scaffold(
snackbarHost = {
LgnSnackbarHost(
hostState = snackbarHostState
snackbar = {
LgnSnackBar(it)
}

Success Snackbar

...
val snackbarHostState = remember { LgnSnackbarHostSate() }
Scaffold(
...
){
Button(
onClick = {
scope.launch{
snackbarHostState.showSnackbarSuccess(...)

Info Snackbar

...
val snackbarHostState = remember { LgnSnackbarHostSate() }
Scaffold(
...
){
Button(
onClick = {
scope.launch{
snackbarHostState.showSnackbarInfo(...)

Error Snackbar

...
val snackbarHostState = remember { LgnSnackbarHostSate() }
Scaffold(
...
){
Button(
onClick = {
scope.launch{
snackbarHostState.showSnackbarError(...)

Warning Snackbar

...
val snackbarHostState = remember { LgnSnackbarHostSate() }
Scaffold(
...
){
Button(
onClick = {
scope.launch{
snackbarHostState.showSnackbarWarning(...)

Custom Snackbar

LgnSnackbar also provide customization in LgnSnackbarHostState.showSnackbar (can be showSnackbarError, etc) have parameters to customize like adjust duration of the snackbar, action button, icon.

Here is the markdown for the parameters of the LgnAccordion function:

...
val snackbarHostState = remember { LgnSnackbarHostSate() }
Scaffold(
...
){
Button(
onClick = {
scope.launch{
snackbarHostState.showSnackbar(

Attributes

ParametersTypeDescription
titleStringText to be shown in the Snackbar
messageStringOptional message text to be shown in the Snackbar
iconImageVectorOptional icon to be shown in the Snackbar
actionLabelStringOptional action label to show as button in the Snackbar
withDismissActionBooleana Boolean to show a dismiss action in the Snackbar.
durationLgnSnackbarDurationDuration to control how long snackbar will be shown in [SnackbarHost], either [LgnSnackbarDuration.Short], [LgnSnackbarDuration.Long] or [LgnSnackbarDuration.Indefinite]