🌍 Public
Viewing a saved revision (read-only)
b8580891459d4e4b8105be2ae8e17e5d
JSX inline styling
This example demonstrates dynamic inline styling in a React component, displaying the current time of day with conditional colors. The App component computes the hour from a fixed Date object, determines whether it is morning or afternoon, and assigns AM/PM labels. Using JavaScript objects for the style prop, the background color switches between purple and green based on the time. The code highlights React’s JSX syntax, where styles are objects rather than strings, and CSS property names use camelCase. ReactDOM renders the component into the root element, with styling applied through inline objects.
AI-generated descriptionReact Starter code.