As stated in the documentation for React on this page:
To define a CSS class, it is recommended to use the className attribute. This applies to
all regular DOM and SVG elements such as <div>
, <a>
, and others.
If you happen to be using React with Web Components (although not common), then the class attribute would be used instead.
Using class
as an attribute will pass down without any validation to the underlying DOM element, but this approach is not preferred. The preferred method is using the className
attribute which is recognized by React.
The React documentation advises using the cannonical React attribute
names rather than traditional JavaScript naming conventions. Even though React does allow attributes to be passed through to the DOM, doing so will result in a warning message.