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

196
Views
FontAwesome inside React JSX

I am trying to insert font-awesome icons inside react, where I want to set the placeholder of input as search icon

const Search = () => {
  return (
    <>
      <div className="Search">
        <form className="Search__form">
          <img src="" />
          <input
            type="text"
            placeholder="&#xF002; Search"
            style="font-family:Arial, FontAwesome"
          ></input>

          <button>Search</button>
        </form>
      </div>
    </>
  );
};

I got this error

Error: The style prop expects a mapping from style properties to values, not a string. For example, style={{marginRight: spacing + 'em'}} when using JSX.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

It is because JSX is not HTML, in JSX you have to pass style as an Object, and to use javascript we have to put a {} and then inside first {} put your styles in an object, but style keys should be in camelCase

Eg:

  • background-color: green => backgroundColor: 'green'
const Search = () => {
  return (
    <>
      <div className="Search">
        <form className="Search__form">
          <img src="" />
          <input
            type="text"
            placeholder="&#xF002; Search"
            style={{fontFamily:"Arial, FontAwesome"}}
          ></input>

          <button>Search</button>
        </form>
      </div>
    </>
  );
};
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!