The Color Scheme Preference Detector is a Nuget library that I recently developed to make it easy to tell if a user prefers dark or light themes, which I saw could be used with Blazor. Here is a small article to explain its origin and operation.
The origin of the idea of the library
The operation is therefore rather simple, we start by checking if the browser supports the function matchMedia, otherwise we return a default value for a light theme. If it supports it, which is the case for recent browsers, we check the preference of the media query to return true / false depending on preference towards the dark theme.
Interop for use with Blazor