Blazor inline css rendering with condition

Michael Scotfield 26 Reputation points
2022-07-05T03:33:10.6+00:00

Hi,

I'm new in using Blazor... I have a question, how to properly render an inline css with condition?

for example... <div class="@tutor .IsActive?d-none:d-block">

Is this possible in Blazor?

Thank you in advance!

Developer technologies .NET Blazor
{count} votes

Accepted answer
  1. Anonymous
    2022-07-05T07:57:58.81+00:00
    <div class=@(bgColor?"mycss-blue":"mycss-red")>test color</div>  
          
        @code {  
            private bool bgColor = true;  
        }  
    

    I did test like this and it worked for me.

    217661-image.png


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Best regards,
    Tiny

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.