Blazor

How do you render elements with conditional attributes?

How do you render elements with conditional attributes?

DOM attributes are rendered based on .NET parameters. If the parameter value is true, the attribute is rendered minimized, otherwise it’s not. Refer to the code example to render the checked attribute conditionally.

 <input type="checkbox" checked="@IsChecked">
  
 @code {
     [Parameter]
     public bool IsChecked { get; set; }
 } 
Sumitra Kumari Shaw

An Engineering graduate who Enjoys building things that live on the internet.