Note Style properties use camelCase (backgroundColor, not background-color). Values that need units must include them as strings ("8px"), except for unitless properties like opacity and zIndex which accept numbers.
Note Inline styles use camelCase property names and string/number values. They cannot handle pseudo-classes (:hover), media queries, or keyframe animations. Best for truly dynamic values that change at runtime.
Frequently asked questions
How does React handle style object?
React covers this with 2 copy-ready snippets on this page. The "Inline Style Objects" snippet in React uses `<div style={{ property: value }} />`.
Which code does the React example use?
The "Inline Style Objects" snippet uses `<div style={{ property: value }} />`, from the JSX section of the React cheat sheet.
What other React snippets are shown for "style object"?
Besides "Inline Style Objects", this page also shows "Inline Styles".
Is there anything to watch out for?
Yes. For "Inline Style Objects": Style properties use camelCase (backgroundColor, not background-color). Values that need units must include them as strings ("8px"), except for unitless properties like opacity and zIndex which accept numbers.