> For the complete documentation index, see [llms.txt](https://swift-packages.gitbook.io/materialuikit/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://swift-packages.gitbook.io/materialuikit/components/tab-bar.md).

# Tab Bar

### Overview

The `TabBar` provides a Material UI-styled tab bar for navigation within a view. It positions the tab bar at the bottom of the screen and allows switching between different tab items.&#x20;

To use the `TabBar`, initialize it with a `TabBarItem` binding to the selected tab item and the main content of the view. Add tab items using the `tabBarItem` modifier, specifying the system image and title for each item.&#x20;

### Initializer&#x20;

Creates a container view with a bottom tab bar.

```swift
TabBar(selection: Binding<TabBarItem>, @ViewBuilder content: () -> Content)
```

### Parameters

<table data-header-hidden><thead><tr><th width="220"></th><th></th></tr></thead><tbody><tr><td><strong>Parameter</strong></td><td><strong>Description</strong></td></tr><tr><td><code>selection</code></td><td>Binding to the selected tab item.</td></tr><tr><td><code>content</code></td><td>A closure that returns the main content view of the tab bar.</td></tr></tbody></table>

> For more information regarding the `TabBarItem`, refer to the documentation for the&#x20;
>
> [TabBar Item](/materialuikit/components/tab-bar/tabbar-item.md) model.

### Modifier

Sets up a tab bar item with the specified system image, title, and selection binding.

```swift
tabBarItem(
    systemImage: String,
    titleKey: String,
    selection: Binding<TabBarItem>
)
```

### Example

```swift
@State private var selection = TabBarItem(systemImage: "house.fill", titleKey: "Home")

var body: some View {
    TabBar(selection: $selection) {
        Text("Home View")
            .tabBarItem(systemImage: "house.fill", titleKey: "Home", selection: $selection)
        
        Text("Profile View")
            .tabBarItem(systemImage: "person.fill", titleKey: "Profile", selection: $selection)
        
        Text("Notifications")
            .tabBarItem(systemImage: "bell.fill", titleKey: "Notifications", selection: $selection)
        
        Text("Settings")
            .tabBarItem(systemImage: "gear", titleKey: "Settings", selection: $selection)
    }
}
```

<figure><picture><source srcset="/files/TcIVfO9SZCGe1LDs6czv" media="(prefers-color-scheme: dark)"><img src="/files/OEjbYJ2tsbd87yO3O8qq" alt=""></picture><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://swift-packages.gitbook.io/materialuikit/components/tab-bar.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
