Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

105
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda