Backdrop component built with Material Guidelines for React Native
npm install react-native-backdrop
|
|
$ npm install react-native-backdrop --save
js
import { Backdrop } from "react-native-backdrop";
const App = () => {
const [visible, setVisible] = useState(false);
const handleOpen = () => {
setVisible(true);
};
const handleClose = () => {
setVisible(false);
};
return (
onPress={() => setVisible(true)}
style={{
width: 200,
height: 40,
justifyContent: 'center',
alignItems: 'center',
elevation: 1,
backgroundColor: '#fff',
}}>
Handle Backdrop
visible={visible}
handleOpen={handleOpen}
handleClose={handleClose}
onClose={() => {}}
swipeConfig={{
velocityThreshold: 0.3,
directionalOffsetThreshold: 80,
}}
animationConfig={{
speed: 14,
bounciness: 4,
}}
overlayColor="rgba(0,0,0,0.32)"
backdropStyle={{
backgroundColor: '#fff',
}}>
Backdrop Content
);
}
`
$3
| Prop | Description | Default |
| --------------------- | ------------------------------------------------------------ | -------------------------------------------------------------------------------------------- |
| children | Content of backdrop (required) | |
| visible | Whether the backdrop is visible (required, boolean) | false
| handleOpen | Function to open backdrop (required, function) | () => {} |
| handleClose | Function to close backdrop (required, function) | () => {} |
| beforeClose | Callback that is called before close animation | () => {} |
| afterClose | Callback that is called after close animation | () => {} |
| beforeOpen | Callback that is called before open animation | () => {} |
| afterOpen | Callback that is called after open animation | () => {} |
| animationConfig | Configures Open and Close Animation speed and bounciness | {speed: 14, bounciness: 4} |
| swipeConfig | Configures Swipe Gesture to close backdrop | {velocityThreshold: 0.3, directionalOffsetThreshold: 80} |
| backdropStyle | Style object for backdrop styling | {} |
| containerStyle | Style object for container styling | { backgroundColor: "#fff" } |
| overlayColor | Color of backdrop overlay | rgba(0, 0, 0, 0.32) |
| header | Display custom header in backdrop | () => ( |
| closedHeight | Height of closed backdrop that will be visible and touchable | 0 |
| closeOnBackButton | Close backdrop on back button press on android | false` |