I want to have a button component since all my buttons will be the same size. They should, however, have different colours. Where/how can I specify the colour?
Asked
Active
Viewed 166 times
1
-
You can find your answer here https://stackoverflow.com/questions/41754471/change-button-color-react-native – ESCoder Jun 12 '20 at 15:27
-
Does this answer your question? [change button color react native](https://stackoverflow.com/questions/41754471/change-button-color-react-native) – Adrian Mole Jun 12 '20 at 18:17
1 Answers
0
If you are building your button components on top of react-native Button you could design them to take a this color (and onPress callback) as a prop.
ButtonComponent.js (using Button from https://reactnative.dev/docs/button)
import React from 'react';
import { Button } from 'react-native';
function ButtonComponent(props) {
return <Button onPress={props.onPress} title="My Button Component" color={props.color} />;
}
According to the docs, the color prop decides the "Color of the text (iOS), or background color of the button (Android)"

fadzb
- 429
- 4
- 9