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.

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.

Tab

PropertyTypeDefaultDescription
titleReactText | (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).

Storybook

Live examples coming soon via Storybook.