from dash import Dash, html, callback, Output, Input, _dash_renderer
import dash_mantine_components as dmc
_dash_renderer._set_react_version("18.2.0")
app = Dash(external_stylesheets=dmc.styles.ALL)
positions = ['top-left', 'top-right', 'bottom-left', 'bottom-right', 'top-center', 'bottom-center']
app.layout = dmc.MantineProvider(html.Div(
[
dmc.NotificationProvider(withinPortal=True),
dmc.Center(
dmc.Select(label="Notification Position", data=positions, value="top-right", id="notify-position", w=400),
style={"height": 300, "width": "100%"},
),
html.Div(id="notify-container")
]
))
@callback(
Output("notify-container", "children"),
Input("notify-position", "value"),
prevent_initial_call=True,
)
def notify(value):
return dmc.Notification(
title=f"Notification {value}",
autoClose=False,
action="show",
message="Hello World",
position=value
)
if __name__ == "__main__":
app.run(debug=True)