Common components (e.g. <div>)
All built-in browser components, such as <div>, support some common props and events.
Reference
Common components (e.g. <div>)
<div className="wrapper">Some content</div>
Props
These special React props are supported for all built-in components:
-
children: A React node (an element, a string, a number, a portal, an empty node likenull,undefinedand booleans, or an array of other React nodes). Specifies the content inside the component. When you use JSX, you will usually specify thechildrenprop implicitly by nesting tags like<div><span /></div>. -
dangerouslySetInnerHTML: An object of the form{ __html: '<p>some html</p>' }with a raw HTML string orTrustedHTMLvalue inside. Overrides theinnerHTMLproperty of the DOM node and displays the passed HTML inside. This should be used with extreme caution! If the HTML inside isn't trusted (for example, if it's based on user data), you risk introducing an XSS vulnerability. Read more about usingdangerouslySetInnerHTML. -
ref: A ref object fromuseReforcreateRef, or arefcallback function, or a string for legacy refs. Your ref will be filled with the DOM element for this node. Read more about manipulating the DOM with refs. -
suppressContentEditableWarning: A boolean. Iftrue, suppresses the warning that React shows for elements that both havechildrenandcontentEditable={true}(which normally do not work together). Use this if you're building a text input library that manages thecontentEditablecontent manually. -
suppressHydrationWarning: A boolean. If you use server rendering, normally there is a warning when the server and the client render different content. In some rare cases (like timestamps), it is very hard or impossible to guarantee an exact match. If you setsuppressHydrationWarningtotrue, React will not warn you about mismatches in the attributes and the content of that element. It only works one level deep, and is intended to be used as an escape hatch. Don't overuse it. Read about suppressing hydration errors. -
style: An object with CSS styles, for example{ fontWeight: 'bold', margin: 20 }. Similarly to the DOMstyleproperty, the CSS property names need to be written ascamelCase, for examplefontWeightinstead offont-weight. You can pass strings or numbers as values. If you pass a number, likewidth: 100, React will automatically appendpx("pixels") to the value unless it's a unitless property. We recommend usingstyleonly for dynamic styles where you don't know the style values ahead of time. In other cases, applying plain CSS classes withclassNameis more efficient. Read more aboutclassNameandstyle.
These standard DOM props are also supported for all built-in components:
