Material-design "Snackbar" component for both Android and iOS.
See Google Design for more info on Snackbars.
To use this extension, you have to do the following steps:
-
In your react-native project, run
-
using npm:
npm install react-native-snackbar
-
using yarn:
yarn add react-native-snackbar
-
-
Link the library using
react-native link react-native-snackbar
(learn more about linking. -
Import it in your JS where you want to show a snackbar:
import Snackbar from 'react-native-snackbar';
To show a simple snackbar:
Snackbar.show({
title: 'Hello world',
// Optional duration. Can be one of LENGTH_LONG | LENGTH_SHORT | LENGTH_INDEFINITE.
duration: Snackbar.LENGTH_LONG,
});
Or, to include an action button:
Snackbar.show({
title: 'Hello world',
action: {
title: 'UNDO',
color: 'green',
onPress: () => { /* Do something. */ },
},
});
TODO: Add screenshots 😎