---
title: "axisBehavior(_:)"
framework: SwiftUI
role: symbol
role_heading: Instance Method
platforms: [iOS 27.1+, iPadOS 27.1+]
path: "swiftui/toolbarcontent/axisbehavior(_:)"
---

# axisBehavior(_:)

The bar axis behavior of the toolbar item.

## Declaration

```swift
nonisolated func axisBehavior(_ behavior: ToolbarItemAxisBehavior) -> some ToolbarContent

```

## Parameters

- `behavior`: The axis behavior of the item.

## Discussion

Discussion Use this modifier to control which bar axes a toolbar item can appear in. The following example restricts an item to the horizontal axis. The item can only appear in a horizontal bar. .toolbar {     ToolbarItem(placement: .primaryAction) {         Toggle(isOn: $isOn) { ... }     }     .axisBehavior(.horizontalOnly) } If both horizontal & vertical bars are present and the item is .verticalPreferred, the system prefers placing the item in the vertical bar.

## See Also

### Customizing behaviors

- [ToolbarItemAxisBehavior](swiftui/toolbaritemaxisbehavior.md)
