eagle0504's picture
app updated
746d2f1
---
title: st.text_input
slug: /develop/api-reference/widgets/st.text_input
description: st.text_input displays a single-line text input widget.
---
<Autofunction function="streamlit.text_input" />
<br />
Text input widgets can customize how to hide their labels with the `label_visibility` parameter. If "hidden", the label doesnโ€™t show but there is still empty space for it above the widget (equivalent to `label=""`). If "collapsed", both the label and the space are removed. Default is "visible". Text input widgets can also be disabled with the `disabled` parameter, and can display an optional placeholder text when the text input is empty using the `placeholder` parameter:
```python
import streamlit as st
# Store the initial value of widgets in session state
if "visibility" not in st.session_state:
st.session_state.visibility = "visible"
st.session_state.disabled = False
col1, col2 = st.columns(2)
with col1:
st.checkbox("Disable text input widget", key="disabled")
st.radio(
"Set text input label visibility ๐Ÿ‘‰",
key="visibility",
options=["visible", "hidden", "collapsed"],
)
st.text_input(
"Placeholder for the other text input widget",
"This is a placeholder",
key="placeholder",
)
with col2:
text_input = st.text_input(
"Enter some text ๐Ÿ‘‡",
label_visibility=st.session_state.visibility,
disabled=st.session_state.disabled,
placeholder=st.session_state.placeholder,
)
if text_input:
st.write("You entered: ", text_input)
```
<Cloud src="https://doc-text-input1.streamlit.app/?embed=true" height="400" />