react-native-vector-icons icon indicating copy to clipboard operation
react-native-vector-icons copied to clipboard

Is there a way to set the underlayColor?

Open LongicornYu opened this issue 6 years ago • 8 comments

When pressed on the icon, there is a squared background color. Is there a way to set it as transparent or other colors like the underlayColor property for components in react-native-elements Header.

LongicornYu avatar Aug 18 '18 15:08 LongicornYu

Do you have some example code?

hampustagerud avatar Aug 27 '18 21:08 hampustagerud

any tips / tricks?

RnbWd avatar Sep 03 '18 18:09 RnbWd

@hampustagerud I am seeing this issue too, I have set underlayColor="white"/"transparent and tried activeOpacity={1} but when the Icon.Button is pressed in, it shows a grey background.

<View style={style.drawerHeaderIconContainer}>
  <Icon.Button
    name="small-x"
    size={32}
    color={colors.lightGrey}
    backgroundColor="white"
    style={style.clearButton}
    iconStyle={style.clearIcon}
    onPress={closeDrawer}
    underlayColor="transparent"
    activeOpacity={1}
    />
</View>
  clearButton: {
    backgroundColor: 'white',
    alignSelf: 'flex-end',
    padding: 0,
  },
  clearIcon: {
    marginRight: 7,
    marginLeft: 2,
  },

Here's a video: https://drive.google.com/file/d/1PNRuv80lrUxf9G5FjKozYtkG0fSptT-d/view?usp=sharing

alburdette619 avatar Sep 18 '18 22:09 alburdette619

There might be some issues with how the Icon.Button class passes props to the TouchableHighlight element. When I create buttons with icons I just wrap an Icon with a TouchableOpacity wrapper which handles the touches. If you look at the source you can see how the button is implemented and you could easily create your own component which you would get full control over 🙂

hampustagerud avatar Sep 20 '18 18:09 hampustagerud

This should work in 6.0.0 if not before.

oblador avatar Oct 02 '18 19:10 oblador

const BLUE = "#428AF8"; const LIGHT_GRAY = "#D3D3D3";

state = { isPress:false, };

onIconPress = async()=> { this.props.onIcon(); await this.setState({isPress:true}); await setTimeout(() => this.setState({isPress: false}), 100); };

<Icon onPress={this.onIconPress} color={isPress ? BLUE : LIGHT_GRAY } />

Manengelo avatar Dec 15 '19 08:12 Manengelo

To set it as transparent you should use prop: activeOpacity={true} (default is false) To set color when pressed button then you can use: underlayColor={'#FFFFFF'}

duongthetrung avatar May 17 '20 02:05 duongthetrung

no also im facing this issue, any help "react-native-vector-icons": "^9.1.0",

akshgods avatar Aug 25 '22 16:08 akshgods

no also im facing this issue, any help "react-native-vector-icons": "^9.1.0",

<Icon suppressHighlighting={true} .../> works

cheymonty avatar Sep 27 '22 23:09 cheymonty