Skip to main content

Drawer

Drawer is a sliding navigation panel typically used for app-wide navigation. It supports grouped items, a header, and a footer.

Import​

import { Drawer, DrawerGroup, DrawerItem } from '@ui-kitten/components';

Basic Usage​

import React, { useState } from 'react';
import { Layout, Drawer, DrawerGroup, DrawerItem, Icon, Text } from '@ui-kitten/components';

const Header = (props) => (
<Layout {...props} style={{ padding: 16 }}>
<Text category="h6">Navigation</Text>
</Layout>
);

const DrawerExample = () => {
const [selectedIndex, setSelectedIndex] = useState(null);

return (
<Drawer
selectedIndex={selectedIndex}
onSelect={(index) => setSelectedIndex(index)}
header={Header}
>
<DrawerItem
title="Home"
accessoryLeft={(props) => <Icon {...props} name="home" />}
/>
<DrawerGroup title="Settings">
<DrawerItem title="Profile" />
<DrawerItem title="Preferences" />
</DrawerGroup>
<DrawerItem title="Logout" />
</Drawer>
);
};

Props​

Drawer​

PropertyTypeDefaultDescription
selectedIndexIndexPathundefinedThe selected drawer item index.
onSelect(index: IndexPath) => void-Called when a drawer item is selected.
header(props) => ReactElementundefinedRender function for the drawer header.
footer(props) => ReactElementundefinedRender function for the drawer footer.
childrenDrawerItem[] | DrawerGroup[]-Drawer items and groups.
appearance'default' | 'noDivider''default'Appearance defined in the Eva mapping. Use noDivider to hide the separators.

DrawerGroup​

PropertyTypeDefaultDescription
titlestring | number | (props) => ReactElement-Group title text or render function.
accessoryLeft(props) => ReactElementundefinedRender function for the left accessory.
childrenDrawerItem[]-Nested drawer items.

DrawerItem​

PropertyTypeDefaultDescription
titlestring | number | (props) => ReactElementundefinedItem title text or render function.
accessoryLeft(props) => ReactElementundefinedRender function for the left accessory.
accessoryRight(props) => ReactElementundefinedRender function for the right accessory.
selectedbooleanfalseWhether the item is rendered as selected. Managed by Drawer.

DrawerItem and DrawerGroup are aliases of MenuItem and MenuGroup and accept exactly the same properties, including initiallyExpanded on the group and all React Native TouchableOpacity props on the item. onPress is called with (descriptor: MenuItemDescriptor, event?: GestureResponderEvent).

Storybook​

Live examples coming soon via Storybook.