SwipeUI

Top tabs

Tabs for sections inside a screen: a label strip with icons, badges and an underline or pill indicator, over swipeable pages.

npx @swipeui/cli add top-tabs
Variant
Preset
Material
Scheme
Feel
Real free component with a browser animation bridge. Native motion, haptics and materials need a device.

When to use it

  • Switching between sibling views inside one screen, such as For you, Following and Trending.
  • Category pages in a store, or Overview, Activity and Settings inside a project.
  • More tabs than fit across the screen: the strip scrolls sideways and keeps the selected one in view.
  • When people expect to swipe left and right between pages as well as tap labels.

When not to use it

  • Top-level app sections. Use a bottom tab bar.
  • Two or three short options that change one setting. Segmented control is smaller.
  • Independent filters that can be combined. Use Chip group or Filter bar.
  • Long, unrelated sections. Separate screens are easier to navigate.

Installation

Run this from your app's root. If SwipeUI isn't set up yet, run npx @swipeui/cli init first; it sets up Uniwind, the theme tokens and the cn helper.

npx @swipeui/cli add top-tabs
  • Adds components/swipeui/tab-bar/top-tabs.tsx and 11 shared helpers.
  • Installs react-native-reanimated, clsx, tailwind-merge, class-variance-authority, uniwind, react-native-worklets, expo-haptics, react-native-gesture-handler. In Expo apps it uses npx expo install so versions match your SDK.

Usage

app/library.tsx
import { TopTabs } from '@/components/swipeui/tab-bar/top-tabs';

<TopTabs value={tab} onValueChange={setTab} tabs={tabs} />;

API reference

PropTypeDefaultDescription
tabsreadonly TopTab[]—

Stable unique destinations, in logical reading order.

value?string—

The selected tab's value, for controlled use.

defaultValue?stringthe first tab

The tab selected first when uncontrolled.

onValueChange?((value: string) => void)—

Called with the next value when a tab is pressed or a page swipe lands.

indicator?"pill" | "underline"'underline'

The mark on the selected tab: a line under it, or a soft capsule behind it.

fit?"equal" | "scroll"'scroll'

scroll sizes each tab to its label and lets the strip scroll; equal shares the width between the tabs.

lazy?booleanfalse

Mounts a page the first time its tab is selected, instead of mounting every page at once.

swipeEnabled?booleantrue

Lets people swipe between pages. Tabs can always be pressed.

disabled?booleanfalse

Turns off pressing and swiping.

haptics?booleantrue

Plays a selection tick when the tab changes.

messages?TabBarMessages—

Replaces the built-in spoken wording, such as "Active, 2 new".

motion?MotionOverridethe app feel

Local motion feel or spring override.

className?string—

Classes merged over the container.

style?StyleProp<ViewStyle>—

Style escape hatch for the container.

testID?string—

The container gets testID, each tab ${testID}-${value}, the pager ${testID}-pages and the indicator ${testID}-indicator.

Composition and behavior

  • tabs lists each tab's value, label and page content in reading order.
  • A scrollable label strip with a sliding underline sits above the swipeable pages.
  • Control it with value and onValueChange, or let it manage itself with defaultValue.
  • swipeEnabled turns page swiping on or off; tapping always works.
  • Each tab can have an icon and a badge; the badge is spoken with the label.
  • indicator draws an underline or a pill; fit sizes tabs to their labels (scroll) or shares the width (equal).
  • lazy mounts a page the first time its tab is selected.

Behavior and gestures

  • Tap a label to jump to its page; the underline slides to it and you feel a light selection tick.
  • Swipe the page area sideways to move to the next or previous tab; the underline follows your finger.
  • The label strip scrolls on its own to keep the selected tab visible.
  • Turning swipeEnabled off keeps tapping but stops page swipes, which helps when a page has its own horizontal gestures.
  • When disabled, neither taps nor swipes change the selection.

Accessibility

  • The strip is a tab list; each label is a tab with selected and disabled states.
  • Pages you can't see are hidden from screen readers, so only the selected page is read.
  • Tapping a label is always available, so swiping is never required.
  • In right-to-left languages the tabs and pages follow reading order.
  • Give each tab a short label; use accessibilityLabel when the visible text is ambiguous.

Motion

  • Uses the press and select motion roles, so it follows your app's feel. Pass motion to tune this one instance.
  • The underline tracks the page swipe continuously, then settles with the select spring.
  • Under Reduce Motion, pages and the strip jump instead of scrolling smoothly.

Performance

  • Paging uses a native horizontal scroll view, and the underline is driven on the UI thread.
  • All pages are mounted; keep heavy pages lazy inside your own content if needed.

Notes for AI

  • Give every tab a unique value; duplicates throw an error.
  • Give the paging area a real height, for example flex: 1 inside a screen.

Compatibility

Runs onSupported
Expo SDK 57Yes
Expo SDK 58Yes
React Native CLI (with Expo modules)Yes
Expo GoYes
Expo RouterYes
React Navigation 7Yes
iOSYes
AndroidYes

This table describes API support and static bundle checks. Native runtime, device accessibility and bare Uniwind compatibility remain pending.

Related items