Bubble Tab Bar
A React Native bottom tab bar where a rounded pill slides behind the selected tab and the selected tab opens to show its label.
A bottom tab bar where a rounded pill slides behind the selected tab, stretching a little as it travels. The selected tab opens up to show its label next to the icon; the others stay icon-only. Every tab is at least 44 points tall and wide, and the bar is a tablist to screen readers. Built for React Native and Expo with react-native only; this page previews it in the browser through react-native-web.
Installation
CLI
npx @modus-ui/cli add bubble-tab-barManual
- Copy the code from the component tab.
- Create a file at
components/ui/bubble-tab-bar.tsx. - Paste the code.
It needs no packages beyond react-native, which your Expo or React Native app already has.
Usage
An icon can be a node, or a function that receives the tab's current color (white on the pill, muted elsewhere) and returns the node. The bar fills its parent's width.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
tabs | BubbleTab[] | - | The tabs. Each has an id, a label and an icon. |
value | string | - | The id of the selected tab. |
onChange | (id: string) => void | - | Called with the id of the tab that was pressed. |
colors | Partial<BubbleTabBarColors> | - | Overrides bar, pill, active and inactive. |
style | StyleProp<ViewStyle> | - | Style for the bar. |
Comments