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

188
Visualizações
Put input text and submit button same line

I am writing a search box and search submission button, I try several way to make the button and text box in same line, but doesn't work. Here is my code.

  return (
    <Form onSubmit={submitHandler} inline>
      <Form.Control
        type='text'
        name='q'
        onChange={(e) => setKeyword(e.target.value)}
        placeholder='Serach product'
        className='mr-sm-2 ml-sm-5'
      ></Form.Control>
      <Button type='submit' variant='btn btn-success' className='p-2'>
          search
      </Button>
    </Form>
  )

What I expect is

But what I have is

Reactjs version is ^17.0.1 in my package.jason file, but when I use npm info react in cmd it shows me react@18.1.0

Thanks the answer from Mr.Gandhi https://stackoverflow.com/a/72385731/19202374

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

Change the input and/or the button to be display: inline in the css Or you can just put display flex on the parent container of the input and button.

about 4 years ago · Juan Pablo Isaza Relatório

0

Wrap your form elements in a div and give a className (ex: flex-container).

return (
    <Form onSubmit={submitHandler} inline>
      <div className="flex-container">
                <Form.Control
                    type='text'
                    name='q'
                    onChange={(e) => setKeyword(e.target.value)}
                    placeholder='Serach product'
                    className='mr-sm-2 ml-sm-5'
                ></Form.Control>
                <Button type='submit' variant='btn btn-success' className='p-2'>
                        search
                </Button>
        </div>
    </Form>
  )

After that add below css

.flex-container {
  display: flex;
}
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