Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

484
Views
¿Cómo le doy estilo a un elemento Alert en react-native?

Estoy trabajando con react-native y he creado un elemento Alert.

 Alert.alert( 'Warning', 'bla bla bla', [ {text: 'OK', onPress: () => console.log('OK Pressed')}, ] )

Ahora me gustaría aplicarle algo de estilo. Digamos que quiero aplicarle un color de fondo rojo y un color blanco para el texto.

¿Cómo puedo conseguir esto? ¿Es posible?

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

En realidad, hay una manera de personalizar el texto en los botones, pero está limitado a lo que se proporciona... A continuación se muestra la definición de tipo de React Native. Luego, un ejemplo simple que muestra un botón rojo. Básicamente, el "predeterminado" es azul, "cancelar" está en negrita pero sigue siendo azul y "destructivo" es rojo.

 ** * An Alert button style */ export type AlertButtonStyle = $Enum<{ /** * Default button style */ 'default': string, /** * Cancel button style */ 'cancel': string, /** * Destructive button style */ 'destructive': string, }>; Alert.alert("Look out!", "Hitting reset will wipe all the app's data on your phone. This cannot be undone!", [ {text: 'Reset', onPress: this._doSomethingSerious, style: 'destructive'}, {text: 'Cancel'}, ], {cancelable: false} )
over 4 years ago · Santiago Trujillo Report

0

Puede usar una biblioteca personalizada como react-native-modalbox .

Podrás diseñar el modal como quieras:

 <Modal style={{background: 'red'}} ref={"modal1"}> <Text style={{color: 'white'}}>Basic modal</Text> <Button onPress={this.toggleSwipeToClose} style={styles.btn}>Disable swipeToClose({this.state.swipeToClose ? "true" : "false"})</Button> </Modal>

Puedes abrir el modal usando

 openModal1(id) { this.refs.modal1.open(); }

Mira el ejemplo para ver más opciones.

Bonificación : si desea encontrar una buena biblioteca para react-native, pruebe js.coach

over 4 years ago · Santiago Trujillo Report

0

No creo que esto sea posible, porque el componente Alert de react-native es algo incluido en Android e iOS y no se puede modificar :/

¡Recomiendo este tipo de problema similar aquí !

Nos vemos !

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!