deep-chat icon indicating copy to clipboard operation
deep-chat copied to clipboard

A message bubble of one type supports multiple styles

Open lynnegaogao opened this issue 1 year ago • 1 comments

Hey Ovidijus,

How can I implement multiple styling options for HTML message bubbles?

Currently, I've set the HTML message style to { backgroundColor: "unset", padding: '0px' }, specifically for a recommend button. 1710741471875(1)

This configuration has been applied universally to all HTML bubbles. I'm interested in enriching the presentation of rich text messages using HTML, and I would like to update the HTML style to a more conventional default, such as {shared: { bubble: { color: "black" } }. image

Could you provide guidance on how to dynamically switch between different HTML bubble styles to accommodate various content types effectively?

Looking forward to your reply!

lynnegaogao avatar Mar 18 '24 06:03 lynnegaogao

Hi @trans-for-learn.

If you want to have custom styling for specific messages, I would recommend the use of custom roles. For example, if your message is a recommendation that should use a specific background color (and is positioned on the right), you can use the following message format:

{html: '<div>Give me some recommendations</div>', role: 'recommendation'}

Then in the messageStyles property, you can use the following code:

{
  default: {
    recommendation: {
      bubble: {
        backgroundColor: 'yellow',
        marginRight: '0px',
        marginLeft: 'auto',
      },
    },
  },
}

Note, the reason why you need marginRight: '0px' and marginLeft: 'auto' is because by default, any role that is not "user", will automatically have its message positioned on the left side, hence these properties position it on the right.

Let me know if this helps.

Thanks!

OvidijusParsiunas avatar Mar 18 '24 21:03 OvidijusParsiunas

I will be closing this issue as there has been no further activity.

OvidijusParsiunas avatar May 15 '24 00:05 OvidijusParsiunas