Up until lately, whenever we’d think of changing themes in run-time, we’d immediately go for some sort of a JS/JSX solution. That could be either theming through higher-order components, passing themes as props (usually with the help of React.Context) or using popular libraries like styled-components.
Today, thanks to ‘CSS custom properties’, a.k.a ‘CSS variables’, we shift the weight towards plain CSS. That is to say, there’s still a need for some JavaScript but as you’ll see, it plays a much minor role (as a side note — that should immediately tell you there’s a good chance of performance optimization).