21

I'm working with React Native elements searchbar and am struggling to get these two little lines on the top and bottom to go away - I can't figure out what they are:

Weirdly formatted Searchbar image here

This is my searchbar code:

    <SearchBar placeholder="Search contacts..." 
        data={this.state.searchResultFriendsList}
        ref={(ref) => this.searchBar = ref}
        style= {styles.searchbar} 
        lightTheme round 
        containerStyle={styles.searchcontainer}
    />

And here are my two style snippets:

searchcontainer: {
    backgroundColor: 'white',
    borderWidth: 0, //no effect
    shadowColor: 'white', //no effect
},
searchbar: {
    width: "100%",
    backgroundColor: 'red', //no effect
    borderWidth:0, //no effect
    shadowColor: 'white', //no effect
},

If I change the theme from lightTheme to the default, the lines become darker grey so I know it's related to the SearchBar element itself but hasn't been able to get rid of it by changing the border or shadow.

Wondering if anyone has experienced anything like this before, thanks in advance!

Mario Boss
  • 1,784
  • 3
  • 20
  • 43
alberta
  • 225
  • 2
  • 7

4 Answers4

53

Use borderBottomColor and borderTopColor as transparent with searchcontainer

searchcontainer: {
 backgroundColor: 'white',
 borderWidth: 0, //no effect
 shadowColor: 'white', //no effect
 borderBottomColor: 'transparent',
 borderTopColor: 'transparent'
}

Hope this will help

Prasun
  • 4,943
  • 2
  • 21
  • 23
5

For anyone else looking to remove those borders try setting the width of every border separately:

containerStyle={{
    borderWidth: 0, //no effect
    borderTopWidth: 0, //works
    borderBottomWidth: 0, //works
}}
Getsumi3
  • 211
  • 2
  • 10
4

in new version of react native elements

containerStyle={{
    backgroundColor:"#FBFBFB",
    borderBottomColor: 'transparent',
    borderTopColor: 'transparent'
}}
Mahdi Bashirpour
  • 17,147
  • 12
  • 117
  • 144
0

Full Code :

import {SearchBar} from 'react-native-elements';

<SearchBar
            placeholder="Rechercher"
            onChangeText={this.updateSearch}
            value={search}
            containerStyle={styles.searchBarContainer}
            inputContainerStyle={styles.searchBarInputContainer}
            inputStyle={styles.searchBarInputStyle}
            leftIconContainerStyle={styles.searchBarLeftIconContainer}
            rightIconContainerStyle={styles.searchBarRightIconContainer}
            lightTheme
            placeholderTextColor={styles.placeholderText}
            round
            showCancel
            underlineColorAndroid={styles.placeholderText}
            cancelButtonTitle
            searchIcon={() => <Image source={searchIcon} style={styles.search} />}
          />

searchBarContainer: {
    backgroundColor: COLORS.SEARCHBAR,
    alignSelf: 'center',
    flexDirection: 'row',
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    alignContent: 'center',
    borderBottomColor: 'transparent',
    borderTopColor: 'transparent',
  },
Khaled Boussoffara
  • 1,567
  • 2
  • 25
  • 53