# ui.notify | NiceGUI

[Button: icon:menu]

[](/zh)

[安装](/zh#installation)

[特性](/zh#features)

[演示](/zh#demos)

[文档](/zh/documentation)

[示例](/zh/examples)

[为什么？](/zh#why)

[Button]

[Button]

[Button]

[](https://github.com/zauberzeug/nicegui/)

[Button: icon:more_vert]

# ui.*notify*

## Notification

Displays a notification on the screen.

:message: content of the notification
:position: position on the screen ("top-left", "top-right", "bottom-left", "bottom-right", "top", "bottom", "left", "right" or "center", default: "bottom")
:close_button: optional label of a button to dismiss the notification (default: `False`)
:type: optional type ("positive", "negative", "warning", "info" or "ongoing")
:color: optional color name
:multi_line: enable multi-line notifications

Note: You can pass additional keyword arguments according to `Quasar's Notify API <https://quasar.dev/quasar-plugins/notify#notify-api>`_.

main.py

[Button]

````python
from nicegui import ui

ui.button('Say hi!', on_click=lambda: ui.notify('Hi!', close_button='OK'))

ui.run()
````

## Notification Types

There are different types that can be used to indicate the nature of the notification.

main.py

[Button]

````python
from nicegui import ui

ui.button('negative', on_click=lambda: ui.notify('error', type='negative'))
ui.button('positive', on_click=lambda: ui.notify('success', type='positive'))
ui.button('warning', on_click=lambda: ui.notify('warning', type='warning'))

ui.run()
````

## Multiline Notifications

To allow a notification text to span multiple lines, it is sufficient to set `multi_line=True`.
If manual newline breaks are required (e.g. `\n`), you need to define a CSS style and pass it to the notification as shown in the example.

main.py

[Button]

````python
from nicegui import ui

ui.html('<style>.multi-line-notification { white-space: pre-line; }</style>', sanitize=False)
ui.button('show', on_click=lambda: ui.notify(
    'Lorem ipsum dolor sit amet, consectetur adipisicing elit. \n'
    'Hic quisquam non ad sit assumenda consequuntur esse inventore officia. \n'
    'Corrupti reiciendis impedit vel, '
    'fugit odit quisquam quae porro exercitationem eveniet quasi.',
    multi_line=True,
    classes='multi-line-notification',
))

ui.run()
````

**Nice**GUI

在浏览器中呈现的 Python UI 框架。

[](https://github.com/zauberzeug/nicegui/)

[](https://discord.gg/TEpFeAaF4f)

[](https://www.reddit.com/r/nicegui/)

资源

[文档](/zh/documentation)

[示例](/zh/examples)

[LLM 参考](/llms.txt)

[GitHub](https://github.com/zauberzeug/nicegui/)

[PyPI](https://pypi.org/project/nicegui/)

社区

[讨论区](https://github.com/zauberzeug/nicegui/discussions)

[Discord](https://discord.gg/TEpFeAaF4f)

[Reddit](https://www.reddit.com/r/nicegui/)

[参与贡献](https://github.com/zauberzeug/nicegui/blob/main/CONTRIBUTING.md)

[赞助者](https://github.com/sponsors/zauberzeug)

法律

[法律声明](/zh/imprint_privacy#imprint)

[隐私](/zh/imprint_privacy#privacy)

由 [Zauberzeug](https://zauberzeug.com) 用 NiceGUI 打造

© 2026 [Zauberzeug GmbH](https://zauberzeug.com)