@@ -108,7 +108,8 @@ function styles<V extends VariantOptions<V>>(config: VariantStyleConfig<V>) {
108108 type Props = OptionalIfHasDefault < VariantProps , DefaultProps > ;
109109
110110 return ( props ?: Props ) : StyleProp < ResolvedStyle > => {
111- // Start with base styles
111+ // We'll build up styles in the correct hierarchy: base → variants → compound variants
112+ // Base styles (lowest priority)
112113 let stylesObj : StyleObject = {
113114 ...( config . base || { } ) ,
114115 } ;
@@ -119,7 +120,7 @@ function styles<V extends VariantOptions<V>>(config: VariantStyleConfig<V>) {
119120 ...props ,
120121 } as VariantProps ;
121122
122- // Apply variant styles
123+ // Apply variant styles (overrides base styles)
123124 for ( const [ propName , value ] of Object . entries ( mergedProps ) as [
124125 keyof V ,
125126 keyof VariantProps [ keyof V ] | boolean ,
@@ -148,7 +149,7 @@ function styles<V extends VariantOptions<V>>(config: VariantStyleConfig<V>) {
148149 }
149150 }
150151
151- // Apply compound variants
152+ // Apply compound variants (highest priority before inline styles)
152153 if ( config . compoundVariants ) {
153154 for ( const compound of config . compoundVariants ) {
154155 if (
@@ -328,11 +329,10 @@ export function defineTokens<T extends TokenConfig>(tokenConfig: T): CreateToken
328329 style : resolvedStyle as ResolvedStyle ,
329330 } ) ;
330331
331- // Merge the StyleSheet style with any style passed in props
332+ // Styles hierarchy: base styles → variants → compound variants → inline styles
333+ // Inline styles (propStyle) must have highest priority, so they come last in the array
332334 const mergedStyle = propStyle
333- ? Array . isArray ( propStyle )
334- ? [ styles . style , ...propStyle ]
335- : [ styles . style , propStyle ]
335+ ? [ styles . style , ...( Array . isArray ( propStyle ) ? propStyle : [ propStyle ] ) ]
336336 : styles . style ;
337337
338338 // We need to cast here to handle the component props correctly
0 commit comments