background property.
TouchableNativeFeedback
A wrapper for making views respond properly to touches (Android only). On Android this component uses native state drawable to display touch feedback.
Documentation Index
Fetch the complete documentation index at: /docs/llms.txt
Use this file to discover all available pages before exploring further.
A wrapper for making views respond properly to touches (Android only). On Android this component uses native state drawable to display touch feedback.
background property.
import React, {useState} from 'react';
import {Text, View, StyleSheet, TouchableNativeFeedback} from 'react-native';
import {SafeAreaView, SafeAreaProvider} from 'react-native-safe-area-context';
const App = () => {
const [rippleColor, setRippleColor] = useState(randomHexColor());
const [rippleOverflow, setRippleOverflow] = useState(false);
return (
<SafeAreaProvider>
<SafeAreaView style={styles.container}>
<TouchableNativeFeedback
onPress={() => {
setRippleColor(randomHexColor());
setRippleOverflow(!rippleOverflow);
}}
background={TouchableNativeFeedback.Ripple(
rippleColor,
rippleOverflow,
)}>
<View style={styles.touchable}>
<Text style={styles.text}>TouchableNativeFeedback</Text>
</View>
</TouchableNativeFeedback>
</SafeAreaView>
</SafeAreaProvider>
);
};
const randomHexColor = () => {
return '#000000'.replace(/0/g, function () {
return Math.round(Math.random() * 16).toString(16);
});
};
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
backgroundColor: 'black',
paddingHorizontal: 20,
},
touchable: {
flex: 0.33,
justifyContent: 'center',
backgroundColor: '#eeeeee',
borderColor: 'black',
borderWidth: 1,
},
text: {
alignSelf: 'center',
},
});
export default App;
background| Type |
|---|
| backgroundPropType |
useForeground| Type |
|---|
| bool |
hasTVPreferredFocus Android| Type |
|---|
| bool |
nextFocusDown Android| Type |
|---|
| number |
nextFocusForward Android| Type |
|---|
| number |
nextFocusLeft Android| Type |
|---|
| number |
nextFocusRight Android| Type |
|---|
| number |
nextFocusUp Android| Type |
|---|
| number |
SelectableBackground()static SelectableBackground(
rippleRadius: number | null,
): ThemeAttributeBackgroundPropType;
SelectableBackgroundBorderless()static SelectableBackgroundBorderless(
rippleRadius: number | null,
): ThemeAttributeBackgroundPropType;
Ripple()static Ripple(
color: ColorValue,
borderless: boolean,
rippleRadius?: number | null,
): RippleBackgroundPropType;
| Name | Type | Required | Description |
|---|---|---|---|
| color | string | Yes | The ripple color |
| borderless | boolean | Yes | If the ripple can render outside its bounds |
| rippleRadius | number | No | controls the radius of the ripple effect |
canUseNativeForeground()static canUseNativeForeground(): boolean;
Was this page helpful?
Supported devices
