[Streamlit] html 태그 넣기
🧶 𝗪𝗲𝗯/Streamlit

[Streamlit] html 태그 넣기

 

 

 

 html 태그 넣기 

import streamlit as st

우선 streamlit 을 선언합니다.

st 라는 alias를 사용하겠습니다. (streamlit에서 권장)

 

html = """
    <div style='
        background-color:red;
        color:white;
    '>
        안녕하세요
    </div>
"""

만들고싶은 html 태그를 문자열로 만들어줍니다.

style을 인라인 형태로 적용할 수 있습니다.

 

st.markdown(html, unsafe_allow_html=True)

st.markdown api 를 이용하면 html 태그를 넣을 수 있습니다. unsafe_allow_html 을 True로 해줘야 합니다.

 

 

 

 결과 화면 

결과화면

다음과 같이 html 태그가 streamlit에 적용된 것을 확인할 수 있습니다.

 

 

+ 참고 document

https://docs.streamlit.io/library/api-reference/text/st.markdown

 

Streamlit Docs

Join the community Streamlit is more than just a way to make data apps, it's also a community of creators that share their apps and ideas and help each other make their work better. Please come join us on the community forum. We love to hear your questions

docs.streamlit.io

 

 

 

 

streamlit html streamlit markdown streamlit style


 

728x90