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

182
Views
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 answers
Answer question

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 Report

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 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!