How to Right Justify st.chat_message?

I see that there’s no feature to right justify st.chat_message() for ‘user’ prompts. The 3rd party component, streamlit-chat, has this feature.

Is there a work-around?

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

    .stChatMessage {
        text-align: right;

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