Hi!
Is there any way to access the light/dark/system value of the current user theme inside the c# side? We have some off-the-shelf components that require to know the state (light/dark) so they can fit the same theme - I can only find a function that gets the default not the Current value.
Thanks!
John
Hi,
The current value is stored inside localStorage, you can get current mode by accessing a data-bs-theme localStorage value.
Here is an example:
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if(firstRender){
var state = await JS.InvokeAsync<string>("localStorage.getItem", "data-bs-theme");
await JS.InvokeVoidAsync("console.log", state);
}
}