question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

textInputStyle does not affect whole input box

See original GitHub issue

Issue Description

I am trying to add support for dark mode in my app, but I am having issues with the input bar in gifted chat. I found the textInputStyle property, however it does not seem to cover the whole input bar.

See:
Screenshot

How can I make the rest of the input bar with dark background color?

Steps to Reproduce / Code Snippets

Code I am using:

   return (
      <SafeAreaView style={ styles.container }>
         <GiftedChat
            inverted={true}
            placeholder="Nachricht"
            renderBubble={_renderBubble}
            renderTime={_renderTime}
            renderSend={_renderSend}
            messages={messages}
            onSend={_sendMessage}
            listViewProps={{ style: styles.contentContainer}}
            textInputStyle={styles.contentContainer}
            user={{
               _id: 1,
            }}
         />
      </SafeAreaView>
   );

Additional Information

  • Nodejs version: [FILL THIS OUT]
  • React version: [FILL THIS OUT]
  • React Native version: 0.61.5
  • react-native-gifted-chat version: 0.13.0
  • Platform(s) (iOS, Android, or both?): iOS (simulator)
  • TypeScript version: [FILL THIS OUT]

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6

github_iconTop GitHub Comments

2reactions
mkhoussidcommented, May 16, 2020

Looking at the source code, this is the component to override.

You’d have,

<GiftedChat
  renderInputToolbar={props => <CustomInputToolbar {...props} />}
/>

And CustomInputToolbar.js would look like,

import React from 'react';
import { StyleSheet } from 'react-native';
import { InputToolbar } from 'react-native-gifted-chat';

const styles = StyleSheet.create({
  inputToolbarBackground: {
    backgroundColor: 'blue',
  },
});

export default = props => (
  <InputToolbar containerStyle={styles.inputToolbarBackground} {...props} />
);

Screenshot 2020-05-16 at 18 39 23

2reactions
Trashpantscommented, Apr 14, 2020

I’m trying to theme this too. It seems to be kind of messy to me. For some reason the input on iOS is weirdly skewed and im struggling to align it 😢

The way it seems to be is to override the renderInputToolbar

so you’d have

<GiftedChat
        messages={messages}
        onSend={(message) => {
          console.log(message);
        }}
        user={{
          _id: 1,
        }}
        renderInputToolbar={(props) => MessengerBarContainer(props)}
        renderComposer={(props) => MessengerBar(props)}
        renderSend={(props) => MessengerSend(props)}
 />

and then

import { Composer, InputToolbar, Send } from "react-native-gifted-chat";

const MessengerBarContainer = (props) => {
  return (
    <InputToolbar
      {...props}
      containerStyle={{
        backgroundColor: colors.grey200,
        alignContent: "center",
        justifyContent: "center",
        borderWidth: 0,
        paddingTop: 6,
        marginHorizontal: 6,
        borderRadius: 32,
        borderTopColor: "transparent",
      }}
    />
  );
};
Read more comments on GitHub >

github_iconTop Results From Across the Web

React Native Text Input fields not taking full width even though ...
just try this with only one TextInput return ( <View style={styles.container}> <KeyboardAvoidingView behavior={Platform.OS === "ios" ?
Read more >
A complete guide to TextInput in React Native - LogRocket Blog
Learn how to implement React Native's TextInput component, customize it to collect user inputs, and style your fields with React Native ...
Read more >
TextInput - React Native
TextInput. A foundational component for inputting text into the app via a keyboard. Props provide configurability for several features, ...
Read more >
CSS Forms - W3Schools
If you only want to style a specific input type, you can use attribute selectors: input[type=text] - will only select text fields; input[type=password]...
Read more >
Custom CSS Styles for Form Inputs and Textareas
The date field is unique in that Chrome and Firefox provide formatting and a popup calendar to select from, while Safari offers no...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found