1 | initial version |
To establish a style object to associate with a React component, follow these steps:
const styles = {
container: {
backgroundColor: '#F5F5F5',
padding: '10px'
},
text: {
color: '#333',
fontSize: '16px'
}
};
import React from 'react';
import styles from './styles';
style
prop, for example:function MyComponent() {
return (
<div style={styles.container}>
<p style={styles.text}>Hello, world!</p>
</div>
);
}