simple-react-native-dialog
A simple react native customisable dialog component
Code style
Screenshots
1.Dialog with 2 buttons and callback
Tech/framework used
React-native
Built with
Configuration
simple-react-native-dialog takes a configuration object as a param on showDialog() method.
Property | Type | Required | Example | Default |
---|---|---|---|---|
header | String | false | null | |
info | String | true | ||
primaryButtonText | String | false | NO | |
secondaryButtonText | String | false | YES | |
primaryButtonStyle | Object | false | {backgroundColor: String} | transparent |
primaryButtonTextStyle | Object | false | {color: String} | black |
secondaryButtonStyle | Object | false | {backgroundColor: String} | transparent |
secondaryButtonTextStyle | Object | false | {color: String} | black |
buttonAlignment | String | false | "center", "left" | right |
primaryButtonPress | Function | false | ()=>{alert('hi')} | void |
secondaryButtonPress | Function | false | ()=>{alert('hi')} | void |
-To enable the secondary button just pass the secondaryButtonPress property.
Code Example
;;; const instructions = Platform; { Dialog } { return <View style=stylescontainer> <Text style=styleswelcome>Welcome to React Native!</Text> <Text style=stylesinstructions>To get started edit Appjs</Text> <Text style=stylesinstructions>instructions</Text> <TouchableOpacity style=stylesbutton onPress=thishandleClick > <Text style=stylesbuttonText>Show Dialog</Text> </TouchableOpacity> <Dialog /> </View> ; } const styles = StyleSheet;
Installation
yarn: yarn add simple-react-native-dialog
npm: npm install --save simple-react-native-dialog
How to use?
- import it in your project
;
- Declare it in your component
<View> <OtherComponents /> <Dialog /></View>
- Trigger it in a function call
{ Dialog }