A SwiftUI library that provides a custom alternative to MenuBarExtra, allowing you to display custom views in the macOS menu bar.
menubarextraplus.mp4
- macOS 15.0+
- Swift 6.2+
Add the following to your Package.swift:
dependencies: [
.package(url: "https://github.com/yshrkt/MenuBarExtraPlus.git", from: "0.1.0")
]Or add it via Xcode:
- File → Add Packages...
- Enter the repository URL:
https://github.com/yshrkt/MenuBarExtraPlus.git
import MenuBarExtraPlus
import SwiftUI
@main
struct MyApp: App {
var body: some Scene {
MenuBarExtraPlus {
// Custom content view shown on left click
MyContentView()
} label: {
// Menu bar label
Image(systemName: "star")
}
}
}MenuBarExtraPlus {
// Custom content view shown on left click
MyContentView()
} rightClickMenu: {
// Menu shown on right click
MenuItem(title: "Item 1", action: { })
MenuItem.divider()
MenuItem(title: "Item 2", action: { })
} label: {
// Menu bar label
Image(systemName: "star")
}Use rightClickContent to display a custom view instead of a menu on right click:
MenuBarExtraPlus {
// Custom content view shown on left click
MyContentView()
} rightClickContent: {
// Custom view shown on right click
MyRightClickContentView()
} label: {
// Menu bar label
Image(systemName: "star")
}Customize behavior with MenuBarExtraPlusConfiguration:
MenuBarExtraPlusPlus(
configuration: .init(
contentOffset: .init(x: -8, y: 0),
rightClickContentOffset: .init(x: 30, y: 0),
menuBarItemClickInterval: 0.3,
ignoresOtherApps: true,
isDebug: false
)
) {
// content
} label: {
// label
}| Property | Type | Description |
|---|---|---|
contentOffset |
CGPoint |
Offset position for the content window. Default: .zero |
rightClickContentOffset |
CGPoint |
Offset position for the right-click content/menu. Default: .zero |
menuBarItemClickInterval |
TimeInterval |
Minimum time interval to dismiss on click. Default: 0.3 |
ignoresOtherApps |
Bool |
Whether to activate the app when showing content. Default: true |
isDebug |
Bool |
Shows debug overlay (red background) when true. Default: false |
Use isInserted binding to show/hide the menu bar item:
@State private var isInserted = true
MenuBarExtraPlus(isInserted: $isInserted) {
// content
} label: {
// label
}MIT License. See LICENSE for details.