@@ -96,20 +96,36 @@ function createCustomButtons(
9696 buttons : AlertButton [ ] | null ,
9797 inputField ?: string
9898) : void {
99- buttons ?. forEach ( ( { text, style, onPress } , index ) => {
99+ buttons ?. forEach ( ( { text, style, onPress, isPreferred } , index ) => {
100100 const button = document . createElement ( 'button' ) ;
101101 button . innerText = text || 'OK' ;
102102
103- // Apply appropriate button styling
103+ // Determine button variant based on priority:
104+ // 1. Destructive style (highest priority)
105+ // 2. Preferred button
106+ // 3. Fallback: first button in 2-button dialog (if second isn't preferred)
107+ // 4. Default: secondary
108+ const baseClass = 'rn-alert__button' ;
109+ let variantClass : string ;
110+
104111 if ( style === 'destructive' ) {
105- button . className = 'rn-alert__button rn-alert__button--destructive' ;
106- } else if ( index === 0 && buttons . length === 2 ) {
107- // First button in two-button dialog gets primary styling
108- button . className = 'rn-alert__button rn-alert__button--primary' ;
112+ variantClass = 'rn-alert__button--destructive' ;
113+ } else if ( isPreferred === true ) {
114+ variantClass = 'rn-alert__button--primary' ;
109115 } else {
110- button . className = 'rn-alert__button rn-alert__button--secondary' ;
116+ const isFirstButtonInTwoButtonDialog =
117+ index === 0 && buttons . length === 2 ;
118+ const secondButtonIsNotPreferred = buttons [ 1 ] ?. isPreferred !== true ;
119+
120+ if ( isFirstButtonInTwoButtonDialog && secondButtonIsNotPreferred ) {
121+ variantClass = 'rn-alert__button--primary' ;
122+ } else {
123+ variantClass = 'rn-alert__button--secondary' ;
124+ }
111125 }
112126
127+ button . className = `${ baseClass } ${ variantClass } ` ;
128+
113129 button . addEventListener ( 'click' , ( ) => {
114130 dialog . close ( ) ;
115131 if ( onPress ) {
0 commit comments