stylex.props
Takes an StyleX style or array of StyleX styles, and returns a props object.
Values can also be null
, undefined
, or false
.
The return value should be onto an element to apply the styles directly.
function props(styles: StyleXStyles | StyleXStyles[]): {
className: string;
style: {[key: string]: string};
};
Example use:
import * as stylex from '@stylexjs/stylex';
const styles = stylex.create({
root: {
backgroundColor: 'red',
padding: '1rem',
paddingInlineStart: '2rem',
},
conditional: {
backgroundColor: 'blue',
},
dynamic: (opacity) => ({
opacity,
}),
});
<div
{...stylex.props(
styles.root,
condition && styles.conditional,
props.style,
styles.dynamic(state.opacity),
)}
/>;