| Function signature[source] |
|---|
st.text(body, *, help=None, width="content", text_alignment="left", wrap=True) |
|---|
| Parameters |
| | |
| |
A tooltip that gets displayed next to the text. If this is None
(default), no tooltip is displayed.
The tooltip can optionally contain GitHub-flavored Markdown,
including the Markdown directives described in the body
parameter of st.markdown.
|
width
("content", "stretch", or int)
|
The width of the text element. This can be one of the following:
- "content" (default): The width of the element matches the
width of its content, but doesn't exceed the width of the parent
container.
- "stretch": The width of the element matches the width of the
parent container.
- An integer specifying the width in pixels: The element has a
fixed width. If the specified width is greater than the width of
the parent container, the width of the element matches the width
of the parent container.
|
text_alignment
("left", "center", "right", or "justify")
|
The horizontal alignment of the text within the element. This can
be one of the following:
- "left" (default): Text is aligned to the left edge.
- "center": Text is centered.
- "right": Text is aligned to the right edge.
- "justify": Text is justified (stretched to fill the available
width with the last line left-aligned).
Note
For text alignment to have a visible effect, the element's
width must be wider than its content. If you use
width="content" with short text, the alignment may not be
noticeable.
|
| |
Whether the text can wrap onto multiple lines. This can be one
of the following:
- True (default): If the text is too wide for the element, it
wraps onto additional lines.
- False: The text stays on one line. Overflow is truncated
with an ellipsis. Newlines in the body are not shown as extra
lines. Truncation only appears when the element is
narrower than its text. Hovering truncated text reveals
the full text, including when help is set.
|
Examples
import streamlit as st
st.text("This is text\n[and more text](that's not a Markdown link).")
Want a new st.text feature or found a bug? Browse open issues and react with a 👍 on the initial post of the ones that matter to you. Your votes help us prioritize what to work on next.
forumStill have questions?
Our forums are full of helpful information and Streamlit experts.