How to load a html form in an iframe

I would like to know how to load the HTML form in the iframe in reactjs.

I have one form component that has all the input fields, and I want to load that form component in the iframe. I would like to know how I can do that.

const Form = () => {
  return (
    <form onSubmit={handleSubmit}>
        <label htmlFor="name">Name</label>
        <label htmlFor="email">Email</label>
        <input type="email" id="email" />

export default Form;

Hi @rishipurwar007,
This article might help: => Best practices for React iframes - LogRocket Blog


1 Like

It worked, but now my Form component styling doesn’t get applied. Any idea how to fix that? I tried to import the styling file for that component directly inside that file, but it still didn’t work.

Read here => javascript - How to set iframe content of a react component - Stack Overflow


This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.