@inject IJSRuntime JsRuntime @if (isVisible) { } else { @(Formatter?.Invoke(Value) ?? (IsPassword ? string.Join("", Value.Select(x => '*')) : Value)) } @code { [Parameter] public string Value { get; set; } [Parameter] public bool IsPassword { get; set; } = false; [Parameter] public EventCallback ValueChanged { get; set; } [Parameter] public Func? Formatter { get; set; } private bool isVisible { get; set; } = false; private ElementReference elementToFocus; protected override async Task OnAfterRenderAsync(bool firstRender) => await JsRuntime.InvokeVoidAsync("BlazorFocusElement", elementToFocus); }