---
title: "Axis Behavior | Explore SwiftUI"
description: "The bar axis behavior of the toolbar item. Learn how to use Axis Behavior in SwiftUI with visual code examples for iOS, macOS, watchOS, tvOS, and visionOS."
canonical_url: "https://exploreswiftui.com/library/toolbars/axis-behavior"
meta:
  author: "Explore SwiftUI"
  "og:description": "The bar axis behavior of the toolbar item. Learn how to use Axis Behavior in SwiftUI with visual code examples for iOS, macOS, watchOS, tvOS, and visionOS."
  "og:image": "https://exploreswiftui.com/_og/d/c_Component%2Ctitle_Axis%2BBehavior%2Cdescription_The%2Bbar%2Baxis%2Bbehavior%2Bof%2Bthe%2Btoolbar%2Bitem.%2Ccategory_Toolbars%2Cimage_~L2FwaS9pbWFnZXMvMjQ3L3ZhcmlhbnRzLzE2OTI~dj0xNzkwNTg2NDAyMzQ2JnI9MiZ3PTY0MCZoPTQ4MCZmPXBuZw%2CimageMode_fit%2CimagePosition_center%2CimageFrame_~Ym9yZGVyLXJhZGl1czogNXB4IDBweCAwcHggNDdweDsgYm9yZGVyOiAxcHggc29saWQgcmdiYSgwLDAsMCwwLjA2KTsgYm9yZGVyLXJpZ2h0OiAwOyBib3gtc2hhZG93OiAwIC0xMHB4IDUwcHggcmdiYSgzNyw5OSwyMzUsMC4xOCk7%2Cprops_eyJwbGF0Zm9ybXMiOlsiaU9TIiwiaVBhZE9TIl19%2Cp_Ii9saWJyYXJ5L3Rvb2xiYXJzL2F4aXMtYmVoYXZpb3Ii%2Cs_qEGhV9gGxaadQw5s.png"
  "og:image:height": "630"
  "og:image:type": image/png
  "og:image:width": "1200"
  "og:title": "Axis Behavior | Explore SwiftUI"
  "twitter:description": "The bar axis behavior of the toolbar item. Learn how to use Axis Behavior in SwiftUI with visual code examples for iOS, macOS, watchOS, tvOS, and visionOS."
  "twitter:image": "https://exploreswiftui.com/_og/d/c_Component%2Ctitle_Axis%2BBehavior%2Cdescription_The%2Bbar%2Baxis%2Bbehavior%2Bof%2Bthe%2Btoolbar%2Bitem.%2Ccategory_Toolbars%2Cimage_~L2FwaS9pbWFnZXMvMjQ3L3ZhcmlhbnRzLzE2OTI~dj0xNzkwNTg2NDAyMzQ2JnI9MiZ3PTY0MCZoPTQ4MCZmPXBuZw%2CimageMode_fit%2CimagePosition_center%2CimageFrame_~Ym9yZGVyLXJhZGl1czogNXB4IDBweCAwcHggNDdweDsgYm9yZGVyOiAxcHggc29saWQgcmdiYSgwLDAsMCwwLjA2KTsgYm9yZGVyLXJpZ2h0OiAwOyBib3gtc2hhZG93OiAwIC0xMHB4IDUwcHggcmdiYSgzNyw5OSwyMzUsMC4xOCk7%2Cprops_eyJwbGF0Zm9ybXMiOlsiaU9TIiwiaVBhZE9TIl19%2Cp_Ii9saWJyYXJ5L3Rvb2xiYXJzL2F4aXMtYmVoYXZpb3Ii%2Cs_qEGhV9gGxaadQw5s.png"
  "twitter:title": "Axis Behavior | Explore SwiftUI"
---

> Index of every page on this site: [llms.txt](https://exploreswiftui.com/llms.txt)

**Interactive previews**[ iPhone Duo](https://exploreswiftui.com/duo?element=247)

# **Axis Behavior**

The bar axis behavior of the toolbar item.

![Axis Behavior - Preview Not Available](https://exploreswiftui.com/api/images/247/variants/1692?v=1790586402346&r=2&w=800&q=80&f=webp)

### **Platform Compatibility**

iOS 27.1+ iPadOS 27.1+

### **Tags**

### **SwiftUI Code**

[ Docs](<https://developer.apple.com/documentation/swiftui/toolbarcontent/axisbehavior(_:)>)

```
 NavigationStack {
            Text("FooBar")
                .toolbar {
                    ToolbarItem {
                        Button(role: .confirm, action: action)
                    }
                    ToolbarItem {
                        Button(role: .cancel, action: action)
                    }
                    .axisBehavior(.horizontalOnly)
                    ToolbarItem {
                        Button("Foo", action: action)
                    }
                    ToolbarItem {
                        Button("Bar", action: action)
                    }
                    .axisBehavior(.verticalPreferred)
                }
}
```

### **Found an issue or have a suggestion?**

Created: September 24, 2026Updated: September 28, 2026

![Connect Wizard](https://exploreswiftui.com/_ipx/f_webp&q_80&s_48x48/images/connect-wizard-icon.png)

**Connect Wizard**

**Unlock insights App Store Connect doesn’t show you.**

[** Get Started **](https://apps.apple.com/app/apple-store/id6747314580?pt=121213751&ct=Explore%20SwiftUI%20Banner&mt=8)

### **More Toolbars Components **

[**View all **](https://exploreswiftui.com/library/toolbars)

![Prefer Vertical Toolbar Items - iOS on iPhone Duo - Landscape - Closed - Liquid Glass - Light Mode - Preview](https://exploreswiftui.com/api/images/248/variants/1749?v=1790419867105&r=2&w=412&q=75&f=webp)

### **Prefer Vertical Toolbar Items**

A compression behavior that prioritizes keeping toolbar items visible over other elements, such as tabs. By default, tabs are prioritized.

![Toolbar Item Visibility Priority - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview](https://exploreswiftui.com/api/images/238/variants/733?v=1792389091475&r=2&w=412&q=75&f=webp)

### **Toolbar Item Visibility Priority**

Defines the visibility priority for a toolbar item.

![Toolbar Overflow Menu - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview](https://exploreswiftui.com/api/images/237/variants/731?v=1790073478842&r=2&w=412&q=75&f=webp)

### **Toolbar Overflow Menu**

The overflow menu of a toolbar. An overflow menu represents actions that are always placed in the toolbar’s overflow menu, regardless of the toolbar mode, platform, or customizability.

![Pinned Toolbar Item Placement - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview](https://exploreswiftui.com/api/images/236/variants/527?v=1790073478842&r=2&w=412&q=75&f=webp)

### **Pinned Toolbar Item Placement**

A placement that pins the item to the trailing edge of the toolbar.

![Remove Toolbar Item Margin - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview](https://exploreswiftui.com/api/images/235/variants/665?v=1790073478842&r=2&w=412&q=75&f=webp)

### **Remove Toolbar Item Margin**

Configures whether the content margins are removed.

![Title Toolbar Item Placement - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview](https://exploreswiftui.com/api/images/95/variants/279?v=1790073478842&r=2&w=412&q=75&f=webp)

### **Title Toolbar Item Placement**

Places content in the title area

![ToolbarItem Shared Background Visibility - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview](https://exploreswiftui.com/api/images/92/variants/295?v=1790073478842&r=2&w=412&q=75&f=webp)

### **ToolbarItem Shared Background Visibility**

Controls the visibility of the glass background effect on items in the toolbar. In certain contexts, such as the navigation bar on iOS and the window toolbar on macOS, toolbar items will be given a glass background effect that is shared with other items in the same logical grouping

![ToolbarSpacer - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview](https://exploreswiftui.com/api/images/82/variants/106?v=1790073478842&r=2&w=412&q=75&f=webp)

### **ToolbarSpacer**

A standard space item in toolbars

### **Explore Other Components **

[**Browse all **](https://exploreswiftui.com/)

![Glass Effect Container - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview](https://exploreswiftui.com/api/images/96/variants/377?v=1790073478842&r=2&w=412&q=75&f=webp)

### **Glass Effect Container**

A view that combines multiple Liquid Glass shapes into a single shape that can morph individual shapes into one another

![Button Styles - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview](https://exploreswiftui.com/api/images/31/variants/339?v=1790073478842&r=2&w=412&q=75&f=webp)

### **Button Styles**

A type that applies standard interaction behavior and a custom appearance to all buttons within a view hierarchy

![Item Sheet - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview](https://exploreswiftui.com/api/images/136/variants/448?v=1790073478842&r=2&w=412&q=75&f=webp)

### **Item Sheet**

Presents a sheet using the given item as a data source for the sheet’s content. On watchOS, sheets are displayed as fullScreenCover.

![InsetGroupedListStyle - iOS on iPhone - Portrait - Flat Design - Light Mode - Preview](https://exploreswiftui.com/api/images/105/variants/305?v=1790073478842&r=2&w=412&q=75&f=webp)

### **InsetGroupedListStyle**

The list style that describes the behavior and appearance of an inset grouped list.

![Tab View Side Bar Bottom Bar - iPadOS - Landscape - Liquid Glass - Light Mode - Preview](https://exploreswiftui.com/api/images/169/variants/707?v=1790073478842&r=2&w=412&q=75&f=webp)

### **Tab View Side Bar Bottom Bar**

Adds a custom bottom bar to the sidebar of a tab view.

![Default Min List Header Height - iOS on iPhone - Portrait - Flat Design - Light Mode - Preview](https://exploreswiftui.com/api/images/111/variants/310?v=1790073478842&r=2&w=412&q=75&f=webp)

### **Default Min List Header Height**

The default minimum height of a header in a list.

![Role Button With Default Label - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview](https://exploreswiftui.com/api/images/134/variants/424?v=1790073478842&r=2&w=412&q=75&f=webp)

### **Role Button With Default Label**

Creates a button that displays a default label.

![MenuPickerStyle - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview](https://exploreswiftui.com/api/images/180/variants/592?v=1790073478842&r=2&w=412&q=75&f=webp)

### **MenuPickerStyle**

A picker style that presents the options as a menu when the user presses a button, or as a submenu when nested within a larger menu.

```json
{"@context":"https://schema.org","@graph":[{"@id":"https://exploreswiftui.com/#website","@type":"WebSite","description":"A visual library for SwiftUI APIs, components, and modifiers","inLanguage":"en-US","name":"Explore SwiftUI","url":"https://exploreswiftui.com/","publisher":{"@id":"https://exploreswiftui.com/#identity"}},{"@id":"https://exploreswiftui.com/library/toolbars/axis-behavior#webpage","@type":"WebPage","dateModified":"2026-09-28T09:06:42.415Z","datePublished":"2026-09-24T19:23:39.735Z","description":"The bar axis behavior of the toolbar item. Learn how to use Axis Behavior in SwiftUI with visual code examples for iOS, macOS, watchOS, tvOS, and visionOS.","name":"Axis Behavior","url":"https://exploreswiftui.com/library/toolbars/axis-behavior","breadcrumb":{"@id":"https://exploreswiftui.com/library/toolbars/axis-behavior#breadcrumb"},"isPartOf":{"@id":"https://exploreswiftui.com/#website"},"potentialAction":[{"@type":"ReadAction","target":["https://exploreswiftui.com/library/toolbars/axis-behavior"]}],"primaryImageOfPage":{"@id":"https://exploreswiftui.com/#logo"}},{"@id":"https://exploreswiftui.com/#identity","@type":"Organization","description":"A visual library for SwiftUI APIs, components, and modifiers","name":"Explore SwiftUI","url":"https://exploreswiftui.com","logo":{"@id":"https://exploreswiftui.com/#logo"},"sameAs":["https://x.com/Typ0genius","https://mastodon.social/@Typ0genius"]},{"@id":"https://exploreswiftui.com/library/toolbars/axis-behavior#article","dateModified":"2026-09-28T09:06:42.415Z","datePublished":"2026-09-24T19:23:39.735Z","description":"The bar axis behavior of the toolbar item. Learn how to use Axis Behavior in SwiftUI with visual code examples for iOS, macOS, watchOS, tvOS, and visionOS.","headline":"Axis Behavior","inLanguage":"en-US","name":"Axis Behavior","thumbnailUrl":"https://exploreswiftui.com/api/images/247/variants/1692?v=1790586402346&r=2","url":"https://exploreswiftui.com/library/toolbars/axis-behavior","@type":["Article","TechArticle"],"about":{"@type":"Thing","name":"SwiftUI"},"author":{"@id":"https://exploreswiftui.com/#identity"},"image":{"@id":"https://exploreswiftui.com/#/schema/image/1"},"isPartOf":{"@type":"WebSite","name":"Explore SwiftUI","url":"https://exploreswiftui.com"},"mainEntityOfPage":{"@id":"https://exploreswiftui.com/library/toolbars/axis-behavior#webpage"},"publisher":{"@id":"https://exploreswiftui.com/#identity"}},{"@id":"https://exploreswiftui.com/library/toolbars/axis-behavior#/schema/software-source-code/1","@type":"SoftwareSourceCode","codeRepository":"https://developer.apple.com/documentation/swiftui/toolbarcontent/axisbehavior(_:)","codeSampleType":"full example","description":"The bar axis behavior of the toolbar item. Learn how to use Axis Behavior in SwiftUI with visual code examples for iOS, macOS, watchOS, tvOS, and visionOS.","name":"Axis Behavior SwiftUI Example","programmingLanguage":"Swift","runtimePlatform":"SwiftUI","text":" NavigationStack {\n            Text(\"FooBar\")\n                .toolbar {\n                    ToolbarItem {\n                        Button(role: .confirm, action: action)\n                    }\n                    ToolbarItem {\n                        Button(role: .cancel, action: action)\n                    }\n                    .axisBehavior(.horizontalOnly)\n                    ToolbarItem {\n                        Button(\"Foo\", action: action)\n                    }\n                    ToolbarItem {\n                        Button(\"Bar\", action: action)\n                    }\n                    .axisBehavior(.verticalPreferred)\n                }\n}","about":[{"@type":"Thing","name":"SwiftUI"},{"@type":"Thing","name":"Toolbars"},{"@type":"Thing","name":"Axis Behavior"}]},{"@id":"https://exploreswiftui.com/library/toolbars/axis-behavior#breadcrumb","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","name":"Home","item":"https://exploreswiftui.com","position":1},{"@type":"ListItem","name":"Toolbars","item":"https://exploreswiftui.com/library/toolbars","position":2},{"@type":"ListItem","name":"Axis Behavior","item":"https://exploreswiftui.com/library/toolbars/axis-behavior","position":3}]},{"@id":"https://exploreswiftui.com/#logo","@type":"ImageObject","caption":"Explore SwiftUI","contentUrl":"https://exploreswiftui.com/apple-touch-icon.png","inLanguage":"en","url":"https://exploreswiftui.com/apple-touch-icon.png"},{"@id":"https://exploreswiftui.com/#/schema/image/1","@type":"ImageObject","contentUrl":"https://exploreswiftui.com/api/images/247/variants/1692?v=1790586402346&r=2","inLanguage":"en","url":"https://exploreswiftui.com/api/images/247/variants/1692?v=1790586402346&r=2"}]}
```