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)

Set the font for the alert text

Parameters

  • font HSFont

    An HSFont object (e.g., `HSFont.headline()`)

Returns

HSUIAlert - Self for chaining

duration(seconds)

Set how long the alert is displayed

Parameters

  • seconds number

    Duration in seconds (default: 5.0)

Returns

HSUIAlert - Self for chaining

padding(points)

Set the padding around the alert text

Parameters

  • points number

    Padding in points (default: 20)

Returns

HSUIAlert - Self for chaining

position(dict)

Set a custom position for the alert

Parameters

  • dict {[key: string]: any}

    Dictionary with `x` and `y` coordinates

Returns

HSUIAlert - Self for chaining

show()

Show the alert

Parameters

None

Returns

HSUIAlert - Self for chaining (can store reference to close manually)

close()

Close the alert immediately

Parameters

None

Returns

Nothing