Skip to main content

Top Tabs

TabBar renders a horizontal row of tabs at the top of a screen. TabView combines a TabBar with a ViewPager for swipeable tab content.

Import​

import { TabBar, TabView, Tab } from '@ui-kitten/components';

Basic Usage​

TabBar Only​

import React, { useState } from 'react';
import { Layout, TabBar, Tab } from '@ui-kitten/components';

const TabBarExample = () => {
const [selectedIndex, setSelectedIndex] = useState(0);

return (
<Layout style={{ flex: 1 }}>
<TabBar selectedIndex={selectedIndex} onSelect={setSelectedIndex}>
<Tab title="Users" />
<Tab title="Orders" />
<Tab title="Settings" />
</TabBar>
</Layout>
);
};

TabView with Content​

import React, { useState } from 'react';
import { Layout, TabView, Tab, Text } from '@ui-kitten/components';

const TabViewExample = () => {
const [selectedIndex, setSelectedIndex] = useState(0);

return (
<TabView selectedIndex={selectedIndex} onSelect={setSelectedIndex}>
<Tab title="Users">
<Layout style={{ padding: 16 }}>
<Text>Users content</Text>
</Layout>
</Tab>
<Tab title="Orders">
<Layout style={{ padding: 16 }}>
<Text>Orders content</Text>
</Layout>
</Tab>
</TabView>
);
};

Props​

TabBar​

PropertyTypeDefaultDescription
selectedIndexnumber0Index of the currently selected tab.
onSelect(index: number) => void-Called when a tab is selected.
indicatorStyleViewStyleundefinedStyle applied to the active tab indicator.
childrenTab[]-Tab elements.
appearance'default''default'Appearance defined in the Eva mapping.

TabBar also accepts all standard React Native View props.

TabView​

PropertyTypeDefaultDescription
selectedIndexnumber0Index of the currently selected tab.
onSelect(index: number) => void-Called when a tab is selected.
childrenTab[]-Tab elements with content as their children.
tabBarStyleViewStyleundefinedStyle applied to the tab bar.
indicatorStyleViewStyleundefinedStyle applied to the active tab indicator.
swipeEnabledbooleantrueWhether tabs can be changed by swiping the content.
shouldLoadComponent(index: number) => boolean() => truePredicate to lazily load tab content. Return false to skip rendering.
animationDurationnumberundefinedDuration of the tab transition animation, in milliseconds.
onOffsetChange(offset: number) => voidundefinedCalled while the content scrolls, with the current horizontal offset.

TabView is built on ViewPager and accepts its properties too.

Tab​

PropertyTypeDefaultDescription
titlestring | number | (props) => ReactElementundefinedTab title text or render function.
icon(props) => ReactElementundefinedRender function for the tab icon.
childrenReactNodeundefinedContent displayed when the tab is selected (used with TabView).
selectedbooleanfalseWhether the tab is rendered as selected. Managed by TabBar.
onSelect(selected: boolean) => voidundefinedCalled when the tab is selected. Managed by TabBar.
appearance'default''default'Appearance defined in the Eva mapping.

Tab also accepts all standard React Native TouchableOpacity props.

Storybook​

Live examples coming soon via Storybook.