Search code examples
asp.net-corevalidationrequiredmudblazor

I want to change the color of the required field symbol (asterisk) to red


I want to change the color of the required field symbol (asterisk) to red.I'am using Mud-Blazor. I tried it using the below code. this is the image after i apply the code This is the code i'm using for asterisk to show in red color.

<style>
 .mud-input-required::before {
  content: "*";
  color: red;
  margin-right: 2px;
    }

  .mud-label {
   display: flex;
   align-items: center;
    }
</style>

Solution

  • <MudTextField @bind-Value="HelperText" Class="red-asterisk-required" Label="With Helper" Variant="Variant.Outlined" />
    <br>
    <MudTextField @bind-Value="HelperText" Label="With Helper" Variant="Variant.Outlined" />
    
    <style>
    .red-asterisk-required .mud-input-label::after {
        content: " *";
        color: red;
    }
    </style>
    
    @code {
        public string HelperText { get; set; }
    }
    

    refer this Link https://try.mudblazor.com/snippet/wOQIEbEdfXffXybS