Preventing newlines in alert() card strings

Hello Friends:

In the below alert() code, a newline gets inserted between "Value: " and the large value substituted in for x. So the card renders like this:

Value:
10000000000000000000000000000000000000000000

instead of like this:

Value: 1000000000000000000000000 ... (with a wrap around)

Does anyone know how to prevent the newline?

x = 10000000000000000000000000000000000000000000
val = 'Value: ' + str(x)  # Tried this.
val = f"""Value: {x}"""   # And this.
alert(val, dismissible=False, title='INFO:', large=False)

Thank you!

You’re running into the way HTML wraps. If you make your alert large=True, you probably won’t see the wrap.

Changing the way individual elements wrap would involve CSS: CSS word-wrap property and working out how to target the label in the default alert.

1 Like

Thank you. I thought it might be something like that. I’ll leave it be. :slight_smile:

Somewhat fortuitously and learned accidentally, after asking this question I discovered that more flexibility on alert card content formatting was available to me via the technique of placing the content portion of it in a tiny Form with a single RichText component (in Markdown format). I did that because, and you’ll remember this, I needed to purge alert cards. Thank you!

That’s what alert2 does. An alert with a rich text is much more flexible.

1 Like

Oh, wow. I spent yesterday going through all of my alerts, instantiating that same tiny Form for them (and more - I’ll spare the details), and it was not fun. alert2 would have saved me time. Thank you for drawing my attention to it and for the contribution.