<!--
{
  "availability" : [
    "iOS: 27.1.0 -",
    "iPadOS: 27.1.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/ToolbarContent/axisBehavior(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI14ToolbarContentPAAE12axisBehavioryQrAA0c8ItemAxisF0VF"
  },
  "title" : "axisBehavior(_:)"
}
-->

# axisBehavior(_:)

The bar axis behavior of the toolbar item.

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

## Parameters

`behavior`

The axis behavior of the item.

## 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.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)