How can I randomly add CSS attributes to Blazor component from parent layer as Vue did?
I think your approach is fine, it just needs a little abstraction around it to make it readable and easily managed across multiple components.
That's why I created this simple helper function library. It's exactly what you are doing in your code, but offers an API for consistency.
https://www.nuget.org/packages/BlazorComponentUtilities/
As far as I know, right now, Blazor does not offer a built-in way to handle CSS, and Blazor best practices and patterns are not yet available, so you can handle CSS in whatever manner you found fit, including JSInterop.
Below is a link to a library I believe can be very useful to you: https://github.com/chanan/BlazorStyled
Hope this helps...