Anne31415's picture
Update app.py
8d2f0ba
raw
history blame
1.87 kB
import streamlit as st
# Define the HTML and CSS for the cloud-shaped button and text field
cloud_button_html = """
<style>
.cloud-button {
background-color: #FFCC99;
border: none;
color: white;
padding: 10px 20px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
transition-duration: 0.4s;
cursor: pointer;
border-radius: 16px;
box-shadow: 0 6px 6px 0 rgba(0, 0, 0, 0.24), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
position: relative;
}
.cloud-button:after {
content: "";
position: absolute;
top: 100%;
left: 50%;
border-width: 0 15px 10px 15px;
border-style: solid;
border-color: #FFCC99 transparent transparent transparent;
margin-left: -15px;
margin-top: -2px;
}
.text-field {
border: none;
background: transparent;
color: #333;
width: 100%;
text-align: center;
}
</style>
<div style="text-align: center; margin-top: 20px;">
<button class="cloud-button" onclick="handleClick()">
<input type="text" value="this is a text field" class="text-field" readonly />
</button>
</div>
<script>
function handleClick() {
const outputDiv = document.getElementById('output');
if(outputDiv) {
outputDiv.innerText = 'success';
}
}
</script>
"""
# Render the cloud button with Streamlit
st.markdown(cloud_button_html, unsafe_allow_html=True)
# Placeholder for the output text
output = st.empty()
# Update the output text when the button is clicked
if "button_clicked" not in st.session_state:
st.session_state["button_clicked"] = False
if st.session_state["button_clicked"]:
output.text("success")
# Button click handler
with st.form(key="my_form"):
submit_button = st.button("Click me!")
if submit_button:
st.session_state["button_clicked"] = True