Skip to main content

Spread Props

Some components have multiple props used for styling. For example, the ScrollView component has a style prop, a contentContainerStyle prop, an indicatorStyle prop, etc. This library allows you to style all of them at once as shown below.

@ref https://callstack.github.io/react-native-paper/button.html

...
import { ScrollView } from 'react-native';
@styled
class MyComponent extends Component {
styles = styles;
render() {
return (
// Spread the style!
<ScrollView {...this.styles.button} />
);
}
}
// Define props inside styles!
const styles = StyleSheet((o) => {
scrollView: {
style: {
backgroundColor: 'orange',
},
contentContainerStyle: {
flex: 1,
alignItems: 'center',
},
}
});