According to the documentation in react native, the MD3LightTheme theme comes by default, so using the documentation we can modify each of the colors of the theme that we are using, in addition to using the provider. For the background of the button when it is selected, an example would be like this:
import * as React from 'react';
import { SafeAreaView, StyleSheet } from 'react-native';
import { SegmentedButtons } from 'react-native-paper';
import { MD3LightTheme as DefaultTheme, Provider as PaperProvider } from 'react-native-paper';
const theme = {
...DefaultTheme,
colors: {
...DefaultTheme.colors,
secondaryContainer: 'yellow',
},
};
const MyComponent = () => {
const [value, setValue] = React.useState('');
return (
<PaperProvider theme={theme}>
<SafeAreaView style={styles.container}>
<SegmentedButtons
value={value}
onValueChange={setValue}
buttons={[
{
value: 'walk',
label: 'Walking',
},
{
value: 'train',
label: 'Transit',
},
{ value: 'drive', label: 'Driving' },
]}
/>
</SafeAreaView>
</PaperProvider>
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
},
});
export default MyComponent;