Inline
Use inline styles for styles that have a high cardinality (e.g. uses the value of a prop) and not for styles that have a low cardinality.
Why? Generating themed stylesheets can be expensive, so they are best for discrete sets of styles.
// bad
export default function MyComponent({ spacing }) {
return (
<div style={{ display: 'table', margin: spacing }} />
);
}
// good
function MyComponent({ styles, spacing }) {
return (
<div {...css(styles.periodic, { margin: spacing })} />
);
}
export default withStyles(() => ({
periodic: {
display: 'table',
},
}))(MyComponent);