That’s a good suggestion re adding a role to alerts. We’ll add that to our list.
As a work around you could try something like this
from anvil.js.window import document
def my_alert(*args, role=None, **kwargs):
try:
if role is not None:
alert_dom = document.getElementById('alert-modal').querySelector('.modal-dialog')
alert_dom.classList.add('anvil-role-' + role)
return alert(*args, **kwargs)
finally:
if role is not None:
alert_dom.classList.remove('anvil-role-' + role)
then adjust your css to be
.anvil-role-alert .modal-content {
background-color: black;
}