Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

102
Vistas
ReactJS + Button with updating text overflowing/exceeding button size

I've currently got a button module, which, based on an array it is given, generates a button with an Image, and Text. However, now that i started adding translations to the buttons, I noticed that some translations for more complex words, are overflowing out of the button, at an inconsistent way.

Buttons with different language translations

The bottom left is the standard/default text in English. There is some inconsistency that I've yet to sort out, but it's all style from my understand. I am still learning how styling buttons works.

All the other buttons show what happens when a different language is presented/selected/used. The buttons update the text when language is updated, so they are dynamically refreshed with new text.

Each button is generated like this:

return <button
         key={buttonName}
         disabled={disabledStatus}
         style={this.props.buttonStyle}
         onClick={this.handleButtonClick.bind(this, buttonLowerCase)
       >
         <img src={...} alt={buttonName}
         />
         <span style={spacer}/> || This is just {width: '5px'} for seperation||
         {buttonText}
       </button>;

buttonStyle is passed down with following parameters from the module:

{
    width: '100px',
    margin: '5px',
    height: '38px',
    display: 'flex',
    alignItems: "center",
    justifyContent: "left",
};

what are possible solutions to this? Keeping in mind, that the buttons cannot grow to be a bigger size than they are currently. I also do notice that spacer does not seem to be respected, if text is larger than given space, now that I look at it, but have no better solution for forming a bit of space from the text at this point.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

If you absolutely need to force the content into the space of the button without increasing the button size dynamically to match the text length, here are some options:

  1. Break the words. See: "word-break" css property.
  2. Make the text smaller where needed.
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda