Convert an HTML card to a React fragment
Admin ·
A trail signup card already has the copy and fields you need. Convert the markup, then compare the label, input and surrounding text with the original before adding the component to a React project.
Convert the example and verify the field
Open HTML to JSX, select Load example, then choose Convert to JSX. The output starts with an exported ConvertedHtml function. Its React fragment contains an article with className set to trail-card.
Check that the label uses htmlFor with the value email and that the input still has the matching id. The email input is self-closing and keeps the required flag. Its label displays Updates & maps because the source entity has already been decoded.
| HTML source | Converted JSX | What to compare |
|---|---|---|
| class="trail-card" | className={"trail-card"} | The existing CSS class name. |
| for="email" | htmlFor={"email"} | The connection to the input's id. |
| <input id="email" type="email" required> | <input id={"email"} type={"email"} required /> | The field type and required flag. |
| {if available}. | {" {if available}."} | The leading space and visible braces after map. |
React, writing markup with JSXReact DOM, common components and props
Check which parts of a form still need code
Add value="alex@example.org" to the example input and convert again. The input now uses defaultValue, so React uses that string as an initial value and the field stays editable. For a checkbox with a checked attribute, the corresponding initial prop is defaultChecked.
Add an inline onclick attribute or style to the article and convert once more. The omissions panel identifies the affected tag and attribute. Move presentation to your stylesheet and implement any required interactive behavior in the React project.
React DOM, input props and form defaultsReact DOM, common components and props
Review the component before importing it
Copy or download converted.jsx after reviewing the omissions. If the input was an entire page, choose HTML document first. The component uses the body contents and reports omitted head content and wrapper attributes.
The converter writes JSX as plain text. If your component contains an image or link with a permitted address, check that address before rendering the component in your app.
React, writing markup with JSXReact DOM, common components and props
Common questions
Why does the output use braced strings for the article text?
String expressions preserve significant spaces and literal braces. JSX would otherwise read unescaped braces as the start of a JavaScript expression.
How should I handle SVG or a custom element?
These elements are outside the converter's supported subset and appear in the omissions. Review their conversion and integration directly in your React project.