โ๏ธย ย Specialized Inputs
Submitted by Arnaud Miribel
Summary
Polished, specialized text inputs โ phone, email, URL, money, search, password โ built on st.components.v2. Pixel-perfect native Streamlit styling.
Functions
specialized_text_input
A polished, specialized text input that matches native Streamlit styling.
Parameters
label : str
Widget label.
icon : str | None
Deprecated. Present for API compatibility, but label-prefixed icons are
intentionally not rendered. Use adornment_icon (via the convenience
wrappers) to show an icon inside the input field.
prefix : str | None
Text badge inside the left of the input border (e.g. "$").
suffix : str | None
Text badge inside the right of the input border (e.g. ".com").
help : str | None
Tooltip text shown on hover of a right-aligned (?) icon next to the label.
error : str | bool | None
True โ red border. str โ red border + inline message.
input_type : str
HTML <input type> attribute.
keyup : bool
When True the widget reruns on every keystroke instead of only on
blur / Enter. Combine with debounce to avoid excessive reruns.
debounce : int
Milliseconds to debounce keyup events (only relevant when
keyup=True). 0 means no debounce.
Returns
str The current value of the input.
Source code in src/streamlit_extras/specialized_inputs/__init__.py
656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 | |
Import:
- You should add this to the top of your .py file
Examples
example
def example() -> None:
"""Gallery demo shown on the streamlit-extras website."""
import streamlit as st
st.text_input("Text input", placeholder="Text input", help="Help")
st.text_input("Password input", placeholder="Password input", type="password")
st.chat_input(placeholder="Chat input")
pwd = password_input("Password", help="Minimum 8 characters", key="ex_pwd")
if pwd:
st.caption(f"Length: {len(pwd)} chars")
email = email_input("Email address", key="ex_email", label_visibility="collapsed")
if email:
valid = bool(re.match(r"^[^@]+@[^@]+\.[^@]+$", email))
if not valid:
email_input(
"Email address (validated)",
value=email,
error="Please enter a valid email address.",
key="ex_email_val",
)
phone_input("Phone number", help="Include your country code", key="ex_phone")
url_input("Website", placeholder="acme.com", key="ex_url")
amount = money_input("Amount", currency="โฌ", help="Enter a positive value", key="ex_money")
if amount:
st.caption(f"Entered: {amount:.2f} โฌ")
q = search_input("Search", label_visibility="collapsed", key="ex_search")
if q:
st.caption(f"Query: {q!r}")
live = search_input(
"Live search",
placeholder="Type to filterโฆ",
key="ex_search_keyup",
keyup=True,
debounce=300,
)
if live:
st.caption(f"Live value: {live!r}")
specialized_text_input(
"Bluesky handle",
suffix=".bsky.social",
placeholder="yourhandle",
help="Enter your handle without the @",
key="ex_custom",
)