Skip to main content

DrawerNavigation

The DrawerNavigation component in our library is a versatile navigational element commonly used in mobile and web applications to provide users with access to various screens, features, or settings. It typically appears as a side panel that can be swiped in from the edge of the screen or toggled with a menu button. DrawerNavigation organizes app content and functionality into a hierarchical menu structure, allowing users to navigate between different sections or views efficiently. It offers a convenient way to access less frequently used features, settings, or navigation options without cluttering the main interface.

Usage

Basic usage

import {View} from 'react-native';

import {DrawerNavigation} from 'rn-inkpad';

const MyComponent = () => {
return (
<View style={{flex: 1}}>
<DrawerNavigation />
</View>
);
};

Props

NameTypeDefaultDescription
backgroundColorstring#464EE5Drawer background color.
closeIconstringcloseIcon to close the drawer.
collapseIconstringchevron-upIcon to collapse drawer groups.
expandIconstringchevron-downIcon to expand drawer groups
fontSizenumber18Drawer item font size.
iconstringmenuIcon to open the drawer.
iconColorstringDrawer icon color.
iconSizenumber35Drawer icon size.
iconTopnumber50Gap between top and drawer icon.
imageImageSourcePropTypeIt is usually the app logo that goes at the top of the drawer.
imageStylesStyleProp<ImageStyle>Custom styles for your image.
itemIconSizenumber19Drawer item icon size.
itemsItem[]Array of items or group of items in your drawer.
textColorstringDrawer item text color.
textStylesStyleProp<TextStyle>Custom styles for your drawer text item.
widthPercentnumber65Percentage of width that the drawer occupies on the screen.

Item

Information

In the items array you can send elements of type DrawerItem or DrawerGroup.

Note

If you send a DrawerGroup it will be shown as a dropdown list in the DrawerNavigation.

DrawerGroup props

NameTypeRequiredDescription
iconstringYESItem Icon.
itemsDrawerItem[]YESItem dropdown list.
textstringYESItem text.

DrawerItem props

NameTypeRequiredDescription
iconstringYESItem icon.
textstringYESItem text.
onPress() => voidNOCallback that is called when item is pressed.
Information

This navigation only provides the style for your navigation, however to navigate to different screens you must install a navigation package.

Usage with props

import {View} from 'react-native';

import {BottomTabNavigation} from 'rn-inkpad';

import Logo from './assets/rn-logo.png';

const MyComponent = () => {
return (
<View style={{flex: 1}}>
<DrawerNavigation
backgroundColor="#BEF0F3"
image={Logo}
items={[
{icon: 'home', text: 'Home', onPress: () => console.log('Home')},
{
text: 'User',
icon: 'person',
items: [
{
icon: 'person',
text: 'Profile',
onPress: () => console.log('Profile'),
},
{
icon: 'time',
text: 'History',
onPress: () => console.log('History'),
},
{
icon: 'star',
text: 'Starred',
onPress: () => console.log('Starred'),
},
],
},
{
icon: 'cog',
text: 'Settings',
onPress: () => console.log('Settings'),
},
]}
/>
</View>
);
};

Example with props