That is pretty neat! One note about these theme switchers I recently learned:
In production websites, you want to hold off on the theme switch until the user presses a button to confirm. I learned this from an accessibility specialist.
I mentioned this in an article when I switched my blog's settings panel to a dialog that has a submit button:
https://marijkeluttekes.dev/blog/articles/2024/09/12/blog-improvements-headings-and-settings/