study2 / custom_button.py
Maryam Ilka
Create custom_button.py
4eb03cf verified
raw
history blame contribute delete
774 Bytes
import streamlit.components.v1 as components
# کامپوننت اختصاصی
def custom_button(text, key=None):
components.html(
f"""
<!DOCTYPE html>
<html>
<body>
<button id="{key}"
style="background-color:#28a745;color:white;border:none;
border-radius:8px;padding:10px 20px;font-weight:bold;
width:100%;cursor:pointer;"
onclick="sendClick()">
{text}
</button>
<script>
function sendClick() {{
window.parent.postMessage("{key}_clicked", "*");
}}
</script>
</body>
</html>
""",
height=50
)