API Docs

HSUIAlert

A temporary on-screen notification

Displays a message that automatically fades out after a specified duration. Positioned in the center of the screen with a semi-transparent background.

Example

hs.ui.alert("Task completed!")
    .font(HSFont.headline())
    .duration(5)
    .padding(30)
    .show();

Properties

This type has no properties.

Methods

font(font) -> HSUIAlert

Set the font for the alert text
font(font) -> HSUIAlert
Name Type Description
font HSFont An HSFont object (e.g., `HSFont.headline()`)
HSUIAlert
Self for chaining
hs.ui.alert("Hello").font(HSFont.headline()).show()

duration(seconds) -> HSUIAlert

Set how long the alert is displayed
duration(seconds) -> HSUIAlert
Name Type Description
seconds number Duration in seconds (default: 5.0)
HSUIAlert
Self for chaining
hs.ui.alert("Hello").duration(3).show()

padding(points) -> HSUIAlert

Set the padding around the alert text
padding(points) -> HSUIAlert
Name Type Description
points number Padding in points (default: 20)
HSUIAlert
Self for chaining
hs.ui.alert("Hello").padding(30).show()

position(dict) -> HSUIAlert

Set a custom position for the alert
position(dict) -> HSUIAlert
Name Type Description
dict {[key: string]: any} Dictionary with `x` and `y` coordinates
HSUIAlert
Self for chaining
hs.ui.alert("Hello").position({x: 100, y: 100}).show()

show() -> HSUIAlert

Show the alert
show() -> HSUIAlert
HSUIAlert
Self for chaining (can store reference to close manually)
hs.ui.alert("Hello").show()

close() -> None

Close the alert immediately
close() -> None
None
const a = hs.ui.alert("Hello").show()
a.close()