HSUIAlert
TypeHSUIAlert
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
Declaration
font(font) -> HSUIAlert
Parameters
| Name | Type | Description |
|---|---|---|
| font | HSFont | An HSFont object (e.g., `HSFont.headline()`) |
Returns
HSUIAlert
Self for chaining
Example
hs.ui.alert("Hello").font(HSFont.headline()).show()
duration(seconds) -> HSUIAlert
Set how long the alert is displayed
Declaration
duration(seconds) -> HSUIAlert
Parameters
| Name | Type | Description |
|---|---|---|
| seconds | number | Duration in seconds (default: 5.0) |
Returns
HSUIAlert
Self for chaining
Example
hs.ui.alert("Hello").duration(3).show()
padding(points) -> HSUIAlert
Set the padding around the alert text
Declaration
padding(points) -> HSUIAlert
Parameters
| Name | Type | Description |
|---|---|---|
| points | number | Padding in points (default: 20) |
Returns
HSUIAlert
Self for chaining
Example
hs.ui.alert("Hello").padding(30).show()
position(dict) -> HSUIAlert
Set a custom position for the alert
Declaration
position(dict) -> HSUIAlert
Parameters
| Name | Type | Description |
|---|---|---|
| dict | {[key: string]: any} | Dictionary with `x` and `y` coordinates |
Returns
HSUIAlert
Self for chaining
Example
hs.ui.alert("Hello").position({x: 100, y: 100}).show()
show() -> HSUIAlert
Show the alert
Declaration
show() -> HSUIAlert
Returns
HSUIAlert
Self for chaining (can store reference to close manually)
Example
hs.ui.alert("Hello").show()
close() -> None
Close the alert immediately
Declaration
close() -> None
Returns
None
Example
const a = hs.ui.alert("Hello").show()
a.close()