API Docs

Object representing a macOS system menu bar item. Create instances with hs.menubar.create().

Properties

title

string
The current title text, or null if none is set

Methods

setTitle(title) -> None

Set the text title displayed in the menu bar
setTitle(title) -> None
Name Type Description
title JSValue Text to display, or null to remove the title
None
const item = hs.menubar.create()
item.setTitle("Hello")

setIcon(image) -> None

Set the icon displayed in the menu bar
setIcon(image) -> None
Name Type Description
image JSValue An HSImage object, or null to remove the icon
None
const item = hs.menubar.create()
item.setIcon(HSImage.fromSymbol("star.fill"))

setTooltip(tooltip) -> None

Set the tooltip shown when hovering over the menu bar item
setTooltip(tooltip) -> None
Name Type Description
tooltip JSValue Tooltip text, or null to remove the tooltip
None
const item = hs.menubar.create()
item.setTooltip("My menu bar item")

setClickCallback(fn) -> None

Set a callback invoked when the item is clicked (only fires when no menu is set)
setClickCallback(fn) -> None
Name Type Description
fn JSValue A function to call on click, or null to remove the callback
None
const item = hs.menubar.create()
item.setTitle("Click me")
item.setClickCallback(() => console.log("clicked!"))

setMenu(menuOrFn) -> None

Set the menu for this item. Pass an array of menu item objects for a static menu, or a function that returns an array for a dynamic menu populated each time it opens.
setMenu(menuOrFn) -> None
Name Type Description
menuOrFn JSValue Array of menu item objects, a function returning such an array, or null to remove the menu
None
const item = hs.menubar.create()
item.setTitle("Menu")
item.setMenu([
    { title: "Option A", fn: () => console.log("A") },
    { title: "-" },
    { title: "Option B", checked: true, fn: () => console.log("B") }
])

hide() -> None

Remove this item from the menu bar. The item is retained and can be shown again with show().
hide() -> None
None
const item = hs.menubar.create()
item.hide()

show() -> None

Show this item in the menu bar.
show() -> None
None
item.show()

isVisible() -> boolean

Check if this item is currently visible in the menu bar.
isVisible() -> boolean
boolean
true if the item is visible in the menu bar
const visible = item.isVisible()