chanan / BlazorStyled

CSS in Blazor Components
https://blazorstyled.io
The Unlicense
191 stars 19 forks source link

Look into ways to pre-render styles in SSB #3

Open chanan opened 5 years ago

chanan commented 5 years ago

Right now, SSB works like this:

<p class="@div">If everything is working right, the background of this paragraph tag should be pink.</p>

@code {
    private string div;

    protected override async Task OnAfterRenderAsync()
    {
       div = await Styled.Css("background-color: pink;");
       StateHasChanged();
    }
}

While this works, it will cause a small flicker on the browser side because the plain html will be rendered first then "enhanced" with the css.

Is there a way the all the styles can be "pre-rendered" and set down with the html?

BlackFenix2 commented 5 years ago

Maybe the same way Blazor prerenders the .razor files before sending a repsonse to the client? my best guess would be to interop the styled.css() function to a