Supporting markdown in `help` tooltip of inputs?

Howdy.

I’m wondering if there’s any way to support markdown/HTML like syntax in the help argument of inputs (that generates a tooltip on hover).

Use Case:
I have ~100 features in a model split into 10 groups, and I want the user to be able to control how much weight is given to each group. I use this with a number input and ideally include the features that belong in that group in the tooltip of the corresponding input. It’s much more appealing to show a list of 10 features where each feature is on a new line rather than a list of 10 in a row separated by commas. Unfortunately, splitting with ‘\n’ seems to just be ignored.

How possible would this be? Any workarounds? Happy to look into making the changes myself if it’s something feasible.

Thanks!

Markdown is supported in the help text. If you look at this linked thread it discusses line breaks specifically (either by double space or by \n).

Is this something only available in newer versions? I’m running 1.11.0 and do not see markdown supported.

Example code:

import streamlit as st
triple_quote = ''' first line
second line'''
st.number_input('test1', help = triple_quote)
new_line = 'first line \n second line'
st.number_input('test2', help = new_line)

This code does not split the help text into two lines.


EDIT: Solved. You have to use 2 spaces after the end of the line, even if using a newline character. (old line \n). I was mistaken that just a new line would suffice. I was able to get my code working using: info = ' \n'.join(x). (two spaces before \n) Thanks for the help @mathcatsand

It’s certainly plausible for there to be slight markdown syntax variations in older versions. Glad you got it worked out for version 1.11.0 now. :slight_smile:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.