{"id":29866406,"url":"https://github.com/nicfontana/swiftui-customtabview","last_synced_at":"2026-03-08T18:38:00.360Z","repository":{"id":206930529,"uuid":"715751595","full_name":"NicFontana/SwiftUI-CustomTabView","owner":"NicFontana","description":"A SwiftUI component for creating TabView with a custom tab bar.","archived":false,"fork":false,"pushed_at":"2025-07-29T13:00:39.000Z","size":1040,"stargazers_count":63,"open_issues_count":1,"forks_count":8,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-29T15:30:56.138Z","etag":null,"topics":["custom-tabbar","custom-tabbar-swiftui","custom-tabview","custom-tabview-swiftui","ios","macos","swift","swiftui","tabview","tabview-swiftui"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NicFontana.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-11-07T19:01:04.000Z","updated_at":"2025-07-29T12:58:56.000Z","dependencies_parsed_at":"2025-07-29T14:45:08.854Z","dependency_job_id":"792b2d27-c4a8-4312-8ca0-2cbe14d66c32","html_url":"https://github.com/NicFontana/SwiftUI-CustomTabView","commit_stats":{"total_commits":17,"total_committers":2,"mean_commits":8.5,"dds":0.05882352941176472,"last_synced_commit":"6ef1961612710f594eeaf669bf09484ccfebecce"},"previous_names":["nicfontana/swiftui-customtabview"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/NicFontana/SwiftUI-CustomTabView","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NicFontana%2FSwiftUI-CustomTabView","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NicFontana%2FSwiftUI-CustomTabView/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NicFontana%2FSwiftUI-CustomTabView/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NicFontana%2FSwiftUI-CustomTabView/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NicFontana","download_url":"https://codeload.github.com/NicFontana/SwiftUI-CustomTabView/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NicFontana%2FSwiftUI-CustomTabView/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267718204,"owners_count":24133445,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-29T02:00:12.549Z","response_time":2574,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["custom-tabbar","custom-tabbar-swiftui","custom-tabview","custom-tabview-swiftui","ios","macos","swift","swiftui","tabview","tabview-swiftui"],"created_at":"2025-07-30T12:13:37.309Z","updated_at":"2026-03-08T18:38:00.314Z","avatar_url":"https://github.com/NicFontana.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n\u003cimg src=\".github/images/header.png\" height=\"50%\" width=\"50%\"/\u003e\n\n# SwiftUI CustomTabView\n\n![Language](https://img.shields.io/badge/Swift-5-orange?logo=Swift\u0026logoColor=white)\n![Platforms](https://img.shields.io/badge/Platforms-iOS%2013+,%20macOS%2010.15+-white?labelColor=gray\u0026style=flat)\n![License](https://img.shields.io/badge/License-MIT-white?labelColor=blue\u0026style=flat)\n\n\u003c/div\u003e\n\nCustomTabView is a SwiftUI component that empowers developers to create customizable tab views with ease. It is designed to provide maximum flexibility and a seamless user experience.\n\n## Why CustomTabView?\n\n### 1. **Unparalleled Customization**\n\nCustomTabView gives you full control over the appearance of your tab bar.  \nWhether you want a minimalistic design or a vibrant, animated tab bar, all you need to do is tailor the tab bar to fit the visual identity of your app and CustomTabView will take care of the rest.\n\n### 2. **Honored SwiftUI View Lifecycle Updates**\n\nEmbrace the full potential of SwiftUI's view lifecycle updates with CustomTabView. The library seamlessly integrates with [`onAppear(perform:)`](https://developer.apple.com/documentation/swiftui/view/onappear(perform:)), [`onDisappear(perform:)`](https://developer.apple.com/documentation/swiftui/view/ondisappear(perform:)), and [`task(priority:_:)`](https://developer.apple.com/documentation/swiftui/view/task(priority:_:)) methods, ensuring that each time you switch tabs from the tab bar, these lifecycle events are triggered.\n\n\u003e **Note:**  \nThis behavior distinguishes CustomTabView from common custom tab view implementations that rely on a `ZStack` to overlay tab views, potentially missing out on these crucial view lifecycle updates.\n\n### 3. **Preserved View State Between Tab Changes**\n   \nCustomTabView preserves the state of your views between tab changes. Whether you're navigating between tabs while performing essential actions in your app, each return to a previously selected tab guarantees finding the view in the exact state you left it.\n\n\u003e **Note:**  \nThis behavior distinguishes CustomTabView from common custom tab view implementations that use a `switch` mechanism, leading to the recreation of views every time the user switches tabs.\n\n\n\u003cdiv align=\"center\"\u003e\n    \u003cimg src=\".github/example.gif\" height=\"50%\"/\u003e\n\u003c/div\u003e\n\n## Installation\n\n### Swift Package Manager\nAdd this repository as a dependency in your [`Package.swift`](https://developer.apple.com/documentation/swift_packages/package):\n\n```swift\n// swift-tools-version:5.0\n\nimport PackageDescription\n\nlet package = Package(\n    ...,\n    dependencies: [\n        .package(url: \"https://github.com/NicFontana/SwiftUI-CustomTabView.git\", .upToNextMajor(from: \"1.0.0\"))\n    ],\n    ...\n)\n```\n\n### Xcode\nSelect File \\\u003e Swift Packages \\\u003e Add Package Dependency, then enter the following URL:\n\n```\nhttps://github.com/NicFontana/SwiftUI-CustomTabView.git\n```\n\nFor more details, see [Adding Package Dependencies to Your App](https://developer.apple.com/documentation/xcode/adding_package_dependencies_to_your_app).\n\n## Usage\n\nTo integrate CustomTabView into your project, follow these simple steps:\n\n#### 1. Create your custom tab bar:\n```swift\nenum Tab: String, Hashable, CaseIterable {\n    case home, explore, favourites, other\n}\n\nstruct SampleTabBarView: View {\n    @Binding var selection: Tab\n    let onTabSelection: (Tab) -\u003e Void\n\n    var body: some View {\n        HStack {\n            ForEach(Tab.allCases, id: \\.self) { tab in\n                tabBarItem(for: tab)\n                    .frame(maxWidth: .infinity)\n                    .contentShape(Rectangle())\n                    .onTapGesture {\n                        selection = tab\n                        onTabSelection(tab)\n                    }\n            }\n        }\n    }\n\n    private func tabBarItem(for tab: Tab) -\u003e some View {\n        ...\n    }\n}\n```\n\n#### 2. Initialise a `CustomTabView`:\n```swift\nimport SwiftUI\nimport CustomTabView\n\n@main\nstruct CustomTabViewExampleApp: App {\n\n    @State private var selectedTab: Tab = .home\n\n    private var tabBarView: SampleTabBarView {\n        SampleTabBarView(selection: $selectedTab) { tab in\n            print(\"Enjoying a custom TabView\")\n        }\n    }\n\n    var body: some Scene {\n        WindowGroup {\n            CustomTabView(tabBarView: tabBarView, tabs: Tab.allCases, selection: selectedTab) {\n                NavigationView {\n                    Text(\"Home\")\n                        .navigationBarTitle(\"Home\")\n                }\n\n                NavigationView {\n                    Text(\"Explore\")\n                        .navigationBarTitle(\"Explore\")\n                }\n\n                NavigationView {\n                    Text(\"Favourites\")\n                        .navigationBarTitle(\"Favourites\")\n                }\n\n                NavigationView {\n                    Text(\"Other\")\n                        .navigationBarTitle(\"Other\")\n                }\n            }\n        }\n    }\n}\n```\n\n\u003e **Important**  \nThe order of the views **must** be reflected in the provided tab bar.\n\n#### 3. (Optional) Change the tab bar position\nYou can change the tab bar position calling the `tabBarPosition(_:)` method on `CustomTabView`:\n\n```swift\nCustomTabView(tabBarView: tabBarView, tabs: Tab.allCases, selection: selectedTab) {\n    ...\n}\n.tabBarPosition(.edge(.bottom))\n```\n\nSupported positions are:\n- `edge(Edge)`: to place the tab bar at one edge of the screen\n- `floating(Edge)`: to let the tab bar float above the content while staying at one edge of the screen\n\n## Contributions and Issues\n\nContributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request. Let's make CustomTabView even better together.\n\n## Acknowledgments\n\nA special thanks to the team at [Moving Parts](https://movingparts.io/) for their insightful article on [\"Variadic Views in SwiftUI\"](https://movingparts.io/variadic-views-in-swiftui). \nTheir valuable insights and exploration of SwiftUI internals greatly contributed to the development of CustomTabView, allowing me to mimic the elegance of SwiftUI's native component APIs. \n\n## License\n\nCustomTabView is available under the MIT license. See [LICENSE](/LICENSE) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnicfontana%2Fswiftui-customtabview","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnicfontana%2Fswiftui-customtabview","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnicfontana%2Fswiftui-customtabview/lists"}