FaridSafi/react-native-gifted-chat

how can change the color of the message box

dibiro opened this issue ยท 14 comments

I need to change the color of the message box from blue to orange

  renderBubble (props) {
    return (
      <Bubble
        {...props}
        wrapperStyle={{
          right: {
            backgroundColor: Colors.primary
          }
        }}
      />
    )
  }

<GiftedChat
  ...
  renderBubble={this.renderBubble}

I close this issue but create a FAQ in readme to refer it: https://github.com/FaridSafi/react-native-gifted-chat#questions

I see what you're doing but where does that Bubble component come from and how do you import it?

It's just the normal bubble from gifted-chat, but we just override the default styles

import { Bubble } from 'react-native-gifted-chat'

And if i wanna change the text color on bubble ?

renderBubble (props) {
      return (
        <Bubble
          {...props}
          textStyle={{
            right: {
              color: "white"
            },
            left: {
              color: "white"
            }
          }}
        />
      )
    }

Can anyone tell me how can I change the shape of the message box
like this
image

@hackrx i too need to change the shape of this box...

@hackrx Did you find out how to change the shape of message box?

Haven't tried, but it seems that you have to implement your own complete component, like the bubble itself: https://github.com/FaridSafi/react-native-gifted-chat/blob/master/src/Bubble.tsx ๐Ÿค”

how do i change the entire chat background color, and foregrounnd color

@capridigitalmedia This may be helpful
#268 (comment)

Simple solution.

<View style={{backgroundColor: '#yourcolor'}}>
  <GiftedChat ...props />
</View>

@capridigitalmedia
you can use this prop of react native gifted chat to change the background color of
messagesContainerStyle={{backgroundColor:Colors.screenBackgroundColor,}}

Below is a more complete example on how to modify the styles of the text bubbles using functional components:

import { GiftedChat, Bubble } from 'react-native-gifted-chat';
// ...Other imports

export default function ChatScreen() {
  
  const renderBubble = props => { 
    return ( 
      <Bubble 
        {...props} 
        textStyle={{ 
              right: { color: 'blue', backgroundColor:'gray' }, 
        }} 
        wrapperStyle={{
            right: { backgroundColor: 'orange', }, 
            left: { backgroundColor: 'red', }, 
        }} 
      />
    )}
  //... Other necessary code
  
  return (
    <GiftedChat
      renderBubble={renderBubble}
      // Other props..
    />
  );
}