TL;DR: Use the CSS variables, media queries and React with useRef. The whole code can be found in this GitHub repository: https://github.com/marekrozmus/blog-responsive-background-with-react-and-css What I needed lately, was a React component that I could reuse and where the background image could be set by the user. The images came from CMS…