# MaterialSnackbar **Repository Path**: applibgroup/MaterialSnackbar ## Basic Information - **Project Name**: MaterialSnackbar - **Description**: This is a material design component in harmony system, if you want create a beautiful page ,just try it! - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2022-07-12 - **Last Updated**: 2022-07-20 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README MaterialSnackbar/README.md at main · Applib-OpenHarmony/MaterialSnackbar
Skip to content
Applib-OpenHarmony  /   MaterialSnackbar  /  
Tip: Type # to search pull requests
Type ? for help and tips
Tip: Type # to search issues
Type ? for help and tips
Tip: Type # to search discussions
Type ? for help and tips
Tip: Type ! to search projects
Type ? for help and tips
Tip: Type @ to search teams
Type ? for help and tips
Tip: Type @ to search people and organizations
Type ? for help and tips
Tip: Type > to activate command mode
Type ? for help and tips
Tip: Go to your accessibility settings to change your keyboard shortcuts
Type ? for help and tips
Tip: Type author:@me to search your content
Type ? for help and tips
Tip: Type is:pr to filter to pull requests
Type ? for help and tips
Tip: Type is:issue to filter to issues
Type ? for help and tips
Tip: Type is:project to filter to projects
Type ? for help and tips
Tip: Type is:open to filter to open content
Type ? for help and tips
We’ve encountered an error and some results aren't available at this time. Type a new search or try again later.
No results matched your search
Search for issues and pull requests # Search for issues, pull requests, discussions, and projects # Search for organizations, repositories, and users @ Search for projects ! Search for files / Activate command mode > Search your issues, pull requests, and discussions # author:@me Search your issues, pull requests, and discussions # author:@me Filter to pull requests # is:pr Filter to issues # is:issue Filter to discussions # is:discussion Filter to projects # is:project Filter to open issues, pull requests, and discussions # is:open
  • Edit Pins
    Pin to…
  • Watch 0

    Notifications

    Get push notifications on iOS or Android.
Open in github.dev Open in a new github.dev tab
Permalink
main
Switch branches/tags
Go to file
1 contributor

Users who have contributed to this file

Material_UI_Component_Snackbar

Material component Snackbar design in OpenHarmony.

Download & Install

Install using npm

npm i @ohos/materialsnackbar

Usage Instructions

To be able to use snackbars, below import statement must be used

import { MaterialSnackBar ,
  SnackBarModel ,SnackBarType
}  from "@ohos/materialsnackbar"

Access snackbar attributes through a object of SnackBarModel and customize the snackbar(if needed) using setter functions as shown and finally pass the object to MaterialSnackBar and action associated with action button.

Snackbar Designs:

SimpleSnack ( Snackbar with only message )

//Creating object
@State snackBarModel1: SnackBarModel = new SnackBarModel(SnackBarType.SimpleSnack)
//Customization
aboutToAppear(){
    this.snackBarModel1.setSnackBarText("Text associated with SimpleSnack")    //Mandatory
    this.snackBarModel1.setSnackTextColor("#ffffff")
    this.snackBarModel1.setSnackBackColor("#9400D3")
    this.snackBarModel1.setOpacity(1)
    this.snackBarModel1.setTimer(4000)
}
//Passing Customized/Non-customized object to MaterialSnackBar
MaterialSnackBar({
          obj : this.snackBarModel1
        })

s11

OneLineActionSnack ( Snackbar with one line message plus the action button )

//Creating object
@State snackBarModel2: SnackBarModel = new SnackBarModel(SnackBarType.OneLineActionSnack)
//Custom Action 
  SnackButtonAction: () => void = function () {
    console.log("test")
  }
//Customization
aboutToAppear(){
    this.snackBarModel2.setSnackBarText("Text of OneLineActionSnack")       //Mandatory
    this.snackBarModel2.setSnackTextColor("#ffffff")
    this.snackBarModel2.setSnackBackColor("#9400D3")
    this.snackBarModel2.setOpacity(1)
    this.snackBarModel2.setTimer(4000)
    this.snackBarModel2.setButtonText("ACTION")                              //Mandatory
    this.snackBarModel2.setButtonTextColor("#ECD540")
}
//Passing Customized/Non-customized object to MaterialSnackBar
MaterialSnackBar({
          obj : this.snackBarModel2,
          func : this.SnackButtonAction
        })

s22

TwoLineActionSnack ( Snackbar with two line message plus the action button )

//Creating object
@State snackBarModel3: SnackBarModel = new SnackBarModel(SnackBarType.TwoLineActionSnack)
//Custom Action 
  SnackButtonAction: () => void = function () {
    console.log("test")
  }
//Customization
aboutToAppear(){
    this.snackBarModel3.setSnackBarText("Longer text associated with TwoLineActionSnack") //Mandatory
    this.snackBarModel3.setSnackTextColor("#ffffff")
    this.snackBarModel3.setSnackBackColor("#9400D3")
    this.snackBarModel3.setOpacity(1)
    this.snackBarModel3.setTimer(4000)
    this.snackBarModel3.setButtonText("ACTION")                                           //Mandatory
    this.snackBarModel3.setButtonTextColor("#ECD540")
}
//Passing Customized/Non-customized object to MaterialSnackBar
MaterialSnackBar({
          obj : this.snackBarModel3,
          func : this.SnackButtonAction
        })

s33

BigLineActionSnack ( Snackbar with longer two line message plus the longer action button )

//Creating object
@State snackBarModel4: SnackBarModel = new SnackBarModel(SnackBarType.BigTwoLineActionSnack)
//Custom Action 
  SnackButtonAction: () => void = function () {
    console.log("test")
  }
//Customization
aboutToAppear(){
    this.snackBarModel4.setSnackBarText("Longer text associated with   BigTwoLineActionSnack")    //Mandatory
    this.snackBarModel4.setSnackTextColor("#ffffff")
    this.snackBarModel4.setSnackBackColor("#9400D3")
    this.snackBarModel4.setOpacity(1)
    this.snackBarModel4.setTimer(4000)
    this.snackBarModel4.setButtonText("LONGER ACTION")                                             //Mandatory
    this.snackBarModel4.setButtonTextColor("#ECD540")
}
//Passing Customized/Non-customized object to MaterialSnackBar
MaterialSnackBar({
          obj : this.snackBarModel4,
          func : this.SnackButtonAction
        })

s44

Compatibility

Supports OpenHarmony API version 9

Reference:

Design by : Pranav Singh