Bottom Tabs
Expo Router bottom tabs with three labeled destinations and a stateful Home screen.
Install
This example uses Expo Router. First install? Set up the registry in your app.
npx --yes --package=https://native.uipkge.dev/cli/uipkge-native-0.1.1.tgz uipkge-native add bottom-tabsSource files
Expand a file to read the source the installer copies into your app.
app/navigation/bottom-tabs/_layout.tsx
import { Tabs } from 'expo-router'
import { Bookmark, House, UserRound } from 'lucide-react-native'
import { useWindowDimensions } from 'react-native'
import { useSafeAreaInsets } from 'react-native-safe-area-context'
import { useThemeColors } from '@/lib/theme'
export default function BottomTabsLayout() {
const colors = useThemeColors()
const { fontScale } = useWindowDimensions()
const { bottom } = useSafeAreaInsets()
// Keep room for a 24 dp icon, vertical spacing, and the scaled 13 sp label.
const tabBarHeight = 32 + Math.ceil(18 * fontScale) + bottom
return (
<Tabs
backBehavior="history"
screenOptions={{
headerShown: false,
sceneStyle: { backgroundColor: colors.background },
tabBarStyle: { backgroundColor: colors.background, borderTopColor: colors.input, height: tabBarHeight },
tabBarActiveTintColor: colors.foreground,
tabBarInactiveTintColor: colors.mutedForeground,
tabBarLabelStyle: { fontSize: 13 },
}}
>
<Tabs.Screen
name="index"
options={{ title: 'Home', tabBarIcon: ({ color, size }) => <House color={color} size={size} /> }}
/>
<Tabs.Screen
name="saved"
options={{ title: 'Saved', tabBarIcon: ({ color, size }) => <Bookmark color={color} size={size} /> }}
/>
<Tabs.Screen
name="profile"
options={{ title: 'Profile', tabBarIcon: ({ color, size }) => <UserRound color={color} size={size} /> }}
/>
</Tabs>
)
}
app/navigation/bottom-tabs/index.tsx
import { useEffect, useState } from 'react'
import { AccessibilityInfo, Platform } from 'react-native'
import { Button } from '@/components/ui/button'
import { Text } from '@/components/ui/text'
import { NavigationExampleScreen } from '@/lib/navigation-example-screen'
export default function HomeTab() {
const [count, setCount] = useState(0)
useEffect(() => {
if (Platform.OS === 'ios' && count > 0) {
AccessibilityInfo.announceForAccessibilityWithOptions(`Count: ${count}`, { queue: true })
}
}, [count])
return (
<NavigationExampleScreen hasTabBar>
<Text size="title" accessibilityRole="header">
Home
</Text>
<Text variant="muted">Increase the count, switch tabs, then return to Home.</Text>
<Text accessibilityLiveRegion="polite">Count: {count}</Text>
<Button onPress={() => setCount((value) => value + 1)}>Increase count</Button>
</NavigationExampleScreen>
)
}
app/navigation/bottom-tabs/saved.tsx
import { Text } from '@/components/ui/text'
import { NavigationExampleScreen } from '@/lib/navigation-example-screen'
export default function SavedTab() {
return (
<NavigationExampleScreen hasTabBar>
<Text size="title" accessibilityRole="header">
Saved
</Text>
<Text variant="muted">Items you bookmark appear here.</Text>
</NavigationExampleScreen>
)
}
app/navigation/bottom-tabs/profile.tsx
import { Text } from '@/components/ui/text'
import { NavigationExampleScreen } from '@/lib/navigation-example-screen'
export default function ProfileTab() {
return (
<NavigationExampleScreen hasTabBar>
<Text size="title" accessibilityRole="header">
Profile
</Text>
<Text variant="muted">Account details and preferences belong here.</Text>
</NavigationExampleScreen>
)
}
Dependencies
Registry items
npm packages
expo-routerlucide-react-nativereact-native-safe-area-context