StyleXStyles<>
A type that allows any styles generated by StyleX.
It also allows the styles to be nested within arrays and be arbitrarily deep.
Further, null
, undefined
and false
are always accepted.
Further, you can pass in an object type to constrain the styles to specific properties and values:
import type {StyleXStyles} from '@stylexjs/stylex';
type Props = {
// ...
style?: StyleXStyles<{
color?: 'red' | 'blue' | 'green';
padding?: 0 | 4 | 8 | 16 | 32;
backgroundColor?: string;
borderColor?: string;
borderTopColor?: string;
borderEndColor?: string;
borderBottomColor?: string;
borderStartColor?: string;
}>;
};
Any key not defined in the object type will be disallowed.
Only known keys are checked
Due to a TypeScript limitation, any key not in your custom object type will only be disallowed if it's one of the known style properties in the internal StyleX types.
TypeScript will not error if you pass an additional unknown key.