Blazor

How do you conditionally hide the DOM elements?

How do you conditionally hide the DOM elements?

DOM elements are hidden using the hidden attribute. You can conditionally use any .NET parameter to set this attribute to hide the DOM elements.

@page "/"
    
   <p hidden="@IsShow">I am Blazor</p>
    
   <button @onclick="@Show">Show/Hide</button>
  
 @code {
       private bool IsShow   {get;set;} = false;
       private void Show()
       {
           IsShow =   !IsShow;
       }      
 } 
Sumitra Kumari Shaw

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