HomeOur TeamContact

Snackbar

By Utkarsh Lubal
Published in Buttons
June 17, 2022
1 min read
Snackbar

Table Of Contents

01
Introduction
02
Installation
03
Example
04
Tutorial

Introduction

Snackbars provide brief feedback about an operation through a message at the bottom of the screen. Snackbar by default uses onSurface color from theme.

Installation

npm install react-native-paper --save

Example


import * as React from 'react';
import { View, StyleSheet } from 'react-native';
import { Button, Snackbar } from 'react-native-paper';

const App = () => {
  const [visible, setVisible] = React.useState(false);

  const onToggleSnackBar = () => setVisible(!visible);

  const onDismissSnackBar = () => setVisible(false);

  return (
    <View style={styles.container}>
      <Button
       onPress={onToggleSnackBar}>{visible ? 'Hide' : 'Show'}</Button>
      <Snackbar
        visible={visible}
        onDismiss={onDismissSnackBar}
        action={{
          label: 'Undo',
          onPress: () => {
            // Do something
          },
        }}>
        Hey there!
      </Snackbar>
    </View>
  );
};

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: "center",
    alignItems:"center",
  },
  button:{
    borderColor: "black"
    }
});

export default App;

Tutorial


Previous Article
HTML to PDF
Next Article
Titled Icons
Utkarsh Lubal

Utkarsh Lubal

Full Stack Developer

Related Posts

Custom Button 2
Custom Button 2
May 06, 2023
1 min

Quick Links

Advertise with usAbout UsContact Us

Social Media