Skip to content

About

A SwiftUI library that provides a custom alternative to MenuBarExtra

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

MenuBarExtraPlus

A SwiftUI library that provides a custom alternative to MenuBarExtra, allowing you to display custom views in the macOS menu bar.

menubarextraplus.mp4

Requirements

  • macOS 15.0+
  • Swift 6.2+

Installation

Swift Package Manager

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:

  1. File → Add Packages...
  2. Enter the repository URL: https://github.com/yshrkt/MenuBarExtraPlus.git

Usage

Basic Usage

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")
        }
    }
}

With Right Click Menu

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")
}

Right Click with Custom View

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")
}

Configuration

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

Control Visibility

Use isInserted binding to show/hide the menu bar item:

@State private var isInserted = true

MenuBarExtraPlus(isInserted: $isInserted) {
    // content
} label: {
    // label
}

License

MIT License. See LICENSE for details.

About

A SwiftUI library that provides a custom alternative to MenuBarExtra

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages