Holoviz panel notification width is too small for more than a few words so my messages get cut.
Can I wrap text and/or increase default width to e.g. 600 px?
In https://panel.holoviz.org/reference/global/Notifications.html I don't see any direct parameter to change.
From https://panel.holoviz.org/how_to/layout/size.html I get that I can change size of a component with width=600, but notifications are under pn.state and not pn directly so this does not work.
I tried with CSS but I am bad at CSS and did not succeed (most probably because I did it wrong, maybe as it's not doable ?!):
import panel as pn
pn.extension(
notifications=True,
raw_css=[ """
/* increase notifications width and force wrapping */
.bk-notification {
max-width: 720px !important; /* desired width */
width: 720px !important;
white-space: normal !important;
word-break: break-word !important;
overflow-wrap: anywhere !important;
}
""" ]
pn.state.notifications.success("...or not...")
With the kind help of @furas (🙏, see his comments on question) :
I managed to force wraping using the right block name. Using right-click on wanted object in navigator I realized that block name is .notyf__message and not .bk-notification
I succeed in changing the width but it decomes ugly and unreadable due to a fancy arc styling that does not stretch well => so I did not keep it.
I added this not directly in pn.extension, but after it as:
pn.config.raw_css.append("""
/* Toast text */
.notyf__message {
white-space: normal !important; /* allows line break */
word-break: break-word !important;
overflow-wrap: anywhere !important;
text-align: right !important;
}
""")
Note : !important seems required so that styling is effectively applied.
As pointed by @furas, we can increase width but this also need background color adjustement (ideally for each type of notification... for now I put only gray for all).
pn.config.raw_css.append("""
.notyf__toast { /* notfy__toast of notfy__message works*/
white-space: normal !important;
word-break: break-word !important;
overflow-wrap: anywhere !important;
text-align: right !important;
min-width: 800px !important;
background-color: #bbb !important; /*gray*/
}
""")
Based on @furas advice to work on animation, I edited the ripple parameters as such:
pn.config.raw_css.append("""
.notyf__ripple {
width: 150% !important;
height: 200% !important;
border-radius: 0% !important;
}
""")
I also deactivated background-color in notyf__toast as it was not needed anymore.
The ripple is active and final state is OK :