# gorhom/react-native-animated-tabbar architecture

> Architecture diagram of the GitHub repository gorhom/react-native-animated-tabbar, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/gorhom/react-native-animated-tabbar
- Repository: https://github.com/gorhom/react-native-animated-tabbar

## Overview

##### Project type and purpose
- This is an open-source React Native UI component library published as `@gorhom/animated-tabbar`.
- It provides two main components:
- `AnimatedTabBar` – a React Navigation integrated bottom-tab bar.
- `AnimatedTabBarView` – a standalone tab-bar view for any React Native app.
- It ships multiple animation “presets” (bubble, flashy, material) and is written in TypeScript.

##### File structure
- Top-level: configuration files (`babel.config.js`, `tsconfig.json`, `.eslintrc.js`, release scripts, docs).
- `src/`: core library code
- `AnimatedTabBar.tsx`, `AnimatedTabBarView.tsx` – entry points.
- `components/` – shared subcomponents (e.g., `RawButton`).
- `hooks/` – custom React hooks for spacing, visibility, transitions.
- `presets/` – three preset folders, each with its own TabBar, TabBarItem, styles, types.
- `utilities/` – tiny helpers (`noop`, reanimated wrapper).
- `index.ts` – public API.
- `example/`: a runnable React Native demo (iOS & Android) showing usage and integration with React Navigation v4 & v5.
- `docs/`: markdown documentation and animated previews.
- CI / GitHub templates, CONTRIBUTING, CHANGELOG, LICENSE, release templates.

##### README for additional insights
- Confirms architecture: it relies on React Native Reanimated v2, Gesture Handler, Svg.
- Supports standalone and React Navigation integration.
- Presents API surface and customizable props.
- Describes presets and migration.

1) Consumer App (Example or any RN app)
2) AnimatedTabBar package
– Public API layer (`index.ts`)
– `AnimatedTabBar` / `AnimatedTabBarView` components
– Presets module (bubble, flashy, material)
– Shared components & hooks
– Utilities
3) React Native runtime
– JS thread
– Native modules: Reanimated, Gesture Handler, Svg
4) React Navigation (optional integration)
b. Relationships & interactions:
– Consumer App → imports `@gorhom/animated-tabbar` → calls `AnimatedTabBar` or `AnimatedTabBarView`.
– These components use presets (strategy pattern) to render TabBarItems.
– Hooks calculate animation values & spacing, then feed into Reanimated nodes.
– UI rendered by RN’s bridging layer and native modules (reanimated worklets, gesture handler events).
– If React Navigation is used, `AnimatedTabBar` receives navigation props and calls `onIndexChange` to navigate.
c. Architectural patterns / design principles:
– Modular preset architecture (each animation preset is a plug-in).
– Hooks for cross-cutting concerns (spacing, RTL, visibility).
– Single responsibility: core view vs. preset vs. utility vs. hook.
– Separation of API surface (index.ts) from implementation.
d. Relevant technologies:
– React Native & React
– TypeScript
– react-native-reanimated (animation engine)
– react-native-gesture-handler (touch events)
– @react-navigation/bottom-tabs (optional)
– @react-native-community/bob (build tooling)

##### Elements
- from Consumer App to API layer
- API → core component → preset → native modules
- core component ↔ hooks/utilities
- React Navigation → AnimatedTabBar (bidirectional)
- Blue rectangles for JS modules (API, components, presets, hooks).
- Yellow hexagons for build/config (babel, tsconfig).
- Grey parallelogram for Consumer App / Example.

##### Final advice
- Be very detailed: break down the package into entry points, shared modules, preset implementations, hooks, utilities, and external dependencies.
- Don’t overthink: more components = more clarity.
- Use a layered view: top = Consumer App; middle = Library internals; bottom = RN runtime & native modules.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Top Layer: Consumer App
    ConsumerApp["Consumer App (Example App)"]:::consumer

    %% Public API
    ConsumerApp -->|imports| Index["Public API"]:::javascript
    click Index "https://github.com/gorhom/react-native-animated-tabbar/blob/master/src/index.ts"

    %% Core Components
    Index --> AnimatedTabBar["AnimatedTabBar"]:::javascript
    click AnimatedTabBar "https://github.com/gorhom/react-native-animated-tabbar/blob/master/src/AnimatedTabBar.tsx"
    Index --> AnimatedTabBarView["AnimatedTabBarView"]:::javascript
    click AnimatedTabBarView "https://github.com/gorhom/react-native-animated-tabbar/blob/master/src/AnimatedTabBarView.tsx"

    %% Optional Integration
    ReactNavigation["React Navigation"]:::external
    ReactNavigation <--> AnimatedTabBar

    %% Library Internals
    subgraph "AnimatedTabBar Package Internals"
        direction TB

        %% Presets Module
        subgraph Presets
            direction TB
            BubbleEntry["Bubble Preset Entry"]:::javascript
            click BubbleEntry "https://github.com/gorhom/react-native-animated-tabbar/blob/master/src/presets/bubble/index.ts"
            BubbleTabBar["BubbleTabBar"]:::javascript
            click BubbleTabBar "https://github.com/gorhom/react-native-animated-tabbar/blob/master/src/presets/bubble/BubbleTabBar.tsx"
            BubbleItem["BubbleTabBarItem"]:::javascript
            click BubbleItem "https://github.com/gorhom/react-native-animated-tabbar/blob/master/src/presets/bubble/item/BubbleTabBarItem.tsx"
            BubbleStyles["bubble/styles.ts"]:::javascript
            click BubbleStyles "https://github.com/gorhom/react-native-animated-tabbar/blob/master/src/presets/bubble/styles.ts"
            BubbleTypes["bubble/types.ts"]:::javascript
            click BubbleTypes "https://github.com/gorhom/react-native-animated-tabbar/blob/master/src/presets/bubble/types.ts"

            FlashyEntry["Flashy Preset Entry"]:::javascript
            click FlashyEntry "https://github.com/gorhom/react-native-animated-tabbar/blob/master/src/presets/flashy/index.ts"
            FlashyTabBar["FlashyTabBar"]:::javascript
            click FlashyTabBar "https://github.com/gorhom/react-native-animated-tabbar/blob/master/src/presets/flashy/FlashyTabBar.tsx"
            FlashyItem["FlashyTabBarItem"]:::javascript
            click FlashyItem "https://github.com/gorhom/react-native-animated-tabbar/blob/master/src/presets/flashy/item/FlashyTabBarItem.tsx"
            FlashyStyles["flashy/styles.ts"]:::javascript
            click FlashyStyles "https://github.com/gorhom/react-native-animated-tabbar/blob/master/src/presets/flashy/styles.ts"
            FlashyTypes["flashy/types.ts"]:::javascript
            click FlashyTypes "https://github.com/gorhom/react-native-animated-tabbar/blob/master/src/presets/flashy/types.ts"

            MaterialEntry["Material Preset Entry"]:::javascript
            click MaterialEntry "https://github.com/gorhom/react-native-animated-tabbar/blob/master/src/presets/material/index.ts"
            MaterialTabBar["MaterialTabBar"]:::javascript
            click MaterialTabBar "https://github.com/gorhom/react-native-animated-tabbar/blob/master/src/presets/material/MaterialTabBar.tsx"
            MaterialItem["MaterialTabBarItem"]:::javascript
            click MaterialItem "https://github.com/gorhom/react-native-animated-tabbar/blob/master/src/presets/material/item/MaterialTabBarItem.tsx"
            MaterialRipple["MaterialTabBarRipple"]:::javascript
            click MaterialRipple "https://github.com/gorhom/react-native-animated-tabbar/blob/master/src/presets/material/ripple/MaterialTabBarRipple.tsx"
            MaterialStyles["material/styles.ts"]:::javascript
            click MaterialStyles "https://github.com/gorhom/react-native-animated-tabbar/blob/master/src/presets/material/styles.ts"
            MaterialTypes["material/types.ts"]:::javascript
            click MaterialTypes "https://github.com/gorhom/react-native-animated-tabbar/blob/master/src/presets/material/types.ts"
        end

        %% Shared Components
        subgraph "Shared Components"
            RawButton["RawButton"]:::javascript
            click RawButton "https://github.com/gorhom/react-native-animated-tabbar/blob/master/src/components/rawButton/index.ts"
        end

        %% Hooks
        subgraph Hooks
            useSpacing["useTabBarItemSpacing"]:::javascript
            click useSpacing "https://github.com/gorhom/react-native-animated-tabbar/blob/master/src/hooks/useTabBarItemSpacing.ts"
            useFocus["useTabBarItemFocusTransition"]:::javascript
            click useFocus "https://github.com/gorhom/react-native-animated-tabbar/blob/master/src/hooks/useTabBarItemFocusTransition.ts"
            useVisibility["useTabBarVisibility"]:::javascript
            click useVisibility "https://github.com/gorhom/react-native-animated-tabbar/blob/master/src/hooks/useTabBarVisibility.ts"
            useStable["useStableCallback"]:::javascript
            click useStable "https://github.com/gorhom/react-native-animated-tabbar/blob/master/src/hooks/useStableCallback.ts"
            HooksIndex["hooks index"]:::javascript
            click HooksIndex "https://github.com/gorhom/react-native-animated-tabbar/blob/master/src/hooks/index.ts"
        end

        %% Utilities
        subgraph Utilities
            Noop["noop"]:::javascript
            click Noop "https://github.com/gorhom/react-native-animated-tabbar/blob/master/src/utilities/noop.ts"
            ReanimatedUtil["reanimated wrapper"]:::javascript
            click ReanimatedUtil "https://github.com/gorhom/react-native-animated-tabbar/blob/master/src/utilities/reanimated.ts"
            UtilsIndex["utilities index"]:::javascript
            click UtilsIndex "https://github.com/gorhom/react-native-animated-tabbar/blob/master/src/utilities/index.ts"
        end
    end

    %% Interactions
    AnimatedTabBar --> Presets
    AnimatedTabBarView --> Presets
    AnimatedTabBar --> RawButton
    AnimatedTabBarView --> RawButton
    AnimatedTabBar --> Hooks
    AnimatedTabBarView --> Hooks
    AnimatedTabBar --> Utilities
    AnimatedTabBarView --> Utilities

    %% Runtime Layer
    subgraph "React Native Runtime"
        direction TB
        JS["JS Thread"]:::external
        subgraph "Native Modules"
            Reanimated["Reanimated"]:::external
            GestureHandler["Gesture Handler"]:::external
            Svg["Svg"]:::external
        end
    end

    %% Data Flows
    AnimatedTabBar -->|animation values| JS
    AnimatedTabBarView -->|animation values| JS
    Hooks -->|computed values| JS
    Utilities -->|helpers| JS
    JS --> Reanimated
    JS --> GestureHandler
    JS --> Svg

    %% Styles
    classDef javascript fill:#D0E8FF,stroke:#0366d6
    classDef consumer fill:#E0E0E0,stroke:#888888,stroke-dasharray: 5 5
    classDef external fill:#D0FFD6,stroke:#228B22
    classDef config fill:#FFF4B1,stroke:#DAA520
```
