Skip to main content

Style Parsing Priority

useSx accepts styles from multiple sources. When the same property is defined in more than one source, the following priority order determines which value wins.

const props = {
style: { marginTop: 24 }, // #2
sx: { mt: '24px' }, // #3
mt: '24px', // #4
}

const { getStyle, filteredProps } = useSx(props, {
transform: ({ /* ... */ }) => ({ mt: 4 }), // #1
fallback: { mt: 8 }, // #5
});

return <View style={getStyle()} />

Priority (highest to lowest): 1 > 2 > 3 > 4 > 5

PrioritySourceDescription
1transform in useSx optionsComputed values based on resolved props. Highest priority because it overrides user-facing props intentionally.
2style propPlain React Native style prop. Higher than sx/token props for stability during incremental migration.
3sx propObject of token-aware style properties.
4Direct propsToken props passed directly (e.g. ml, color).
5fallback in useSx optionsDefault values applied when no other source provides a value.
tip

If priority ordering is confusing, start with direct props (#4) and transform (#1) only. Add style (#2) and sx (#3) as needed during migration.