Skip to content

Add per-user styling to ChatFeed (ChatInterface) #7939

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

CTPassion
Copy link
Contributor

@CTPassion CTPassion commented May 22, 2025

There is a common requirement to only apply certain styles to users within a chat feed. For me, this was obvious when I wanted to align user and agent messages to the left and right, for a classical conversation UI.

It has been mentioned here holoviz discourse and here #7488

Rather than just providing an alignment kwarg, I believe it more useful to expose the user to the full suite of styling options they may want to apply on a per-user basis. To align right for example, just apply:

ChatInterface(
    ..., 
    user_messages_styles={"user": {"align-self": "flex-end"}}
)

To get it to look correct, I also had to apply some CSS to the .message class:

CHAT_CSS = """
    .message {
        min-height: 15px;
        min-width: fit-content;
        overflow-wrap: normal;
        word-break: normal;
    }
"""
ChatInterface(
    ..., 
    user_messages_styles={"user": {"align-self": "flex-end"}},
    stylesheets=[CHAT_CSS]
)

This way users can not just align messages but also change the colours, fonts, sizes etc. as before, but on a per-user basis rather than globally.

@CTPassion CTPassion marked this pull request as ready for review May 22, 2025 15:56
Copy link

codecov bot commented May 22, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.66%. Comparing base (4d17528) to head (7dea287).

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #7939       +/-   ##
===========================================
+ Coverage   45.33%   86.66%   +41.33%     
===========================================
  Files         334      346       +12     
  Lines       50808    53261     +2453     
===========================================
+ Hits        23032    46161    +23129     
+ Misses      27776     7100    -20676     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants