How to Right Justify st.chat_message?

The code below should do the trick. I also found this CSS hacking tut very helpful, which should help you be able to apply this anything you want more generally.

import streamlit as st

st.markdown(
    """
<style>
    .stChatMessage {
        text-align: right;
    }
</style>
""",
    unsafe_allow_html=True,
)

with st.chat_message("user"):
    st.write("Hello 👋")
    st.write("I'm on the right 👋")
1 Like