Skip to main content

Drawer 🆕

const Drawer = () => {
// drawer functions /
const [isDrawerOpen, setIsDrawerOpen] = useState(false);

const toggleDrawer = () => {
setIsDrawerOpen(!isDrawerOpen);
};

const closeDrawer = () => {
setIsDrawerOpen(false);
};

return (
<View style={styles.container}>
{!isDrawerOpen ? (
<Button title="Toggle Drawer" onPress={toggleDrawer} />
) : (
<Button title="Close Drawer" onPress={closeDrawer} />
)}

<Drawer
isOpen={isDrawerOpen}
onClose={closeDrawer}
backgroundColor="black"
>
<Text>Drawer Content</Text>
<Text>Drawer Content</Text>
<Text>Drawer Content</Text>
<Text>Drawer Content</Text>
<Text>Drawer Content</Text>
<Text>Drawer Content</Text>
</Drawer>
</View>
);
};
const styles = StyleSheet.create({
container: {
alignItems: "center",
justifyContent: "center",
},
});

export default Drawer;

Api References for Drawer

ParameterTypeDescription
isOpen booleanrequire for opening state
onClosevoidclose drawer
childrenReact.ReactNodedrawer content
backgroundColorstringbackground color for drawer
stylestyleViewyour custom styles